Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Problem with Sum function

dpaulajr
Posts: 3
Joined: Sat Jan 28, 2012 11:29 pm
Location: Brazil

Problem with Sum function

Unread post by dpaulajr »

Hi, Steve!

In Report Builder, when I put the the function SUM(field) in a header ou footer section, i got the error attached here ...
sum function.zip
(29.85 KiB) Downloaded 361 times
I see that nuBuilder added the word SUM after the field in SELECT sentence --- SUM(rh_remu_SUM). The field in Detail is only rh_remu.


Thanks,

dePaula Jr.
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

Yes, I'm getting this too. I believe it's a bug as it happens on existing reports in the nufinancials module as well. Simply editing an existing report with a sum function will trigger this error.
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

Just to add: I've phoned nuBuilder, and they are (now) aware of and have confirmed this problem. A fix will be made available shortly.
pickle_jimmy
Posts: 38
Joined: Mon Jul 25, 2011 4:00 am

Re: Problem with Sum function

Unread post by pickle_jimmy »

Hi Danielf (etal)

Steve tells me that this error is caused by having "Magic Quotes" turned on for PHP. Nubuilder doesn't need magic quotes - in fact magic quotes breaks nubuilder, as it takes care of "quote escaping" itself.

So, how do you turn them (magic quotes) off?? There are 2 ways.

1) Turn them off in the php.ini file - find the following lines and change the ONs to OFFs
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off
2) or Add a .htaccess file to your webroot directory containing the following line.
php_flag magic_quotes_gpc Off

WARNING
=========
If your site is hosted on a server that runs PHP in CGI mode - you will not be able to put php_flag directives in a .htaccess file - it will cause a "500 Internal Server Error"
If this is the case, you should be able to create a php.ini file in your webroot directory with just the above php.ini lines rather than a .htaccess file.

so... not so much a nuBuilder bug as a php directive that has since been realised was a bad idea to begin with.

Hope this helps

PJ
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

Jimmy, there appears to be more to this. This error is new to build 2.5 and affects existing reports that use the SUM function. They will run fine out of the box, until you edit them. Go into the financials site, edit the 'invoice list' report, save and run, and it'll throw up this error.

I tried changing magic quotes this end (running the Nubuilder supplied php.ini which has magic_quotes_gpc On and the rest off) and I still get the error on editing a report.

Either way, when I spoke to Shane on the phone, and got him to edit an existing report and then run it, it crashed for him. This doesn't seem to affect specific environments, it includes the source...
pickle_jimmy
Posts: 38
Joined: Mon Jul 25, 2011 4:00 am

Re: Problem with Sum function

Unread post by pickle_jimmy »

Hi Danielf,

Just an update - it seems using the php.ini file works differently to the .htaccess file in that
the settings in the php.ini don't effect the files in subdirectories - this is why the nuBuilder demo site
was still troubled with Magic Quotes - the php.ini needed to go into the productionnu2 directory, not in the webroot.

Cheers

PJ
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

Hi Jimmy,

No joy here, I'm afraid. It tried both moving php.ini into productionnu2, and adding a .htaccess file to wwwroot, and the problem persists (including the demo site). I'm not sure what to try next.

Daniel
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Problem with Sum function

Unread post by admin »

Daniel,

Chances are you'll need to return to a backup as once the report has been saved with magic quotes the report is stuffed.

Steven
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

Hi Steve,

There does appear to be more to this. I've disabled magic quotes and checked this by adding the following code to the 'before open' field for a form:
if(get_magic_quotes_gpc())
echo "Magic quotes are enabled";
else
echo "Magic quotes are disabled";
And it tells me that magic quotes are disabled.

Next, I loaded a fresh (so unaffected) copy of the demo site into phpmyadmin and edited a report that uses the sum function. It throws up the same error. I also get this error with any new report I try to create that uses either the sum or percent function. Any thoughts?

Cheers,

Dan.
danielf
Posts: 44
Joined: Tue Jul 26, 2011 2:48 pm

Re: Problem with Sum function

Unread post by danielf »

In the absence of any response: is there anyone that doesn't have this problem?

The nuBuilder demo site is still affected. I've done an uninstall and reinstalled nuBuilder earlier this week using a fresh download (which has magic quotes turned off in php.ini). Edited the invoice list report, saved it and it crashes, provided you give it something to 'sum' by selecting all customers, and a from date in 2009 or before. The report works 'fine' if there's nothing to sum (as with a from date after 2009). Any new reports created that use the sum function under the new build will crash.

As a workaround, I've found that I can edit reports by reverting to an old copy of productionnu2, and then load them into the new version. That's alright for me, but not for people who don't have an earlier version of productionnu2...

Either way: I'd be more than interested to hear if the sum function works (or not) for other people, be it in new reports, or in the demo site when you select all customers and a from date < 2009.
Locked