Page 1 of 1

[solved] Divide by zero error in news module

Posted: Wed Jun 04, 2008 10:41 pm
by g5todd
Hello, looking for some help here.

I made no changes to the call to the news module but I'm suddenly getting divide by zero errors in both News module 2.6.1 and 2.7.

Here's the call to News module that has started to fail:

Code: Select all

Action Items {news number="8" detailpage="action-items" category="Action Items" makerssbutton="true"}

{news number="8" detailpage="action-items" category="Action Items" dateformat="%B %e, %Y"}
And the error:

Code: Select all

Warning: Division by zero in /home/cippicc/public_html/modules/News/action.default.php on line 176

Warning: Division by zero in /home/cippicc/public_html/modules/News/action.default.php on line 177
Lines 176-177 correspond to:

Code: Select all

  $pagecount = (int)($count / $pagelimit);
  if( ($count % $pagelimit) != 0 ) $pagecount++;
I noticed that pagelimit defaults to 100000. I don't override pagelimit, but even when I overrode it to pagelimit=10 I still get this issue. I have cleared the cache.

Not sure what else to do at this point, any suggestions? TIA

Re: Divide by zero error in news module

Posted: Wed Jun 04, 2008 10:53 pm
by calguy1000
the 'number' paramater is a synonym for pagelimit
however

try this:  add the line:

Code: Select all

if ($pagelimit <= 0 ) $pagelimit = 10000;
directly above that code.

Re: Divide by zero error in news module

Posted: Wed Jun 04, 2008 11:33 pm
by g5todd
Thanks for the hint. Unfortunately that seems to kill the news module. The page containing it takes about 30 seconds longer to load, and when it's done loading the news pane is empty.

Re: Divide by zero error in news module

Posted: Thu Jun 05, 2008 1:10 am
by g5todd
Taking out the number parameters gets rid of the error messages and doesn't take as long to load, but unfortunately the news panes wind up being blank. Everything shows up fine in the News editing pages though.

Re: Divide by zero error in news module

Posted: Thu Jun 05, 2008 1:20 am
by Dr.CSS
Have you tried renaming the alias for the detail page by taking out the - and making the adjustments in your call?

Re: [solved] Divide by zero error in news module

Posted: Thu Jun 05, 2008 1:34 am
by g5todd
Thank you to Ted, calguy1000 and mark.

The issue turned out to be the way the news module was called. Someone edited the page that included the call to the News module and somehow all of the the double quotes wound up being replaced by ". I'm surprised that the news call actually sort-of worked.

Once I changed all the instances of " back to double quotes it worked again.