Division By Zero
Kripsy - March 2, 2008 - 01:13
| Project: | Carousel |
| Component: | Code - views_carousel |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hi, so far the views_carousel module works great and is very easy to configure and use, my only issue is that I keep getting a division by zero error related to the page count.
# user warning: Query was empty query: in /home/.flubberty/krispy/www.projectumbrella.net/includes/database.mysql.inc on line 172.
# warning: Division by zero in /home/.flubberty/krispy/www.projectumbrella.net/sites/all/modules/views_carousel/views_carousel.module on line 108.If I had the view page node count set to say 10 but only had 5 items it would still scroll 5 empty items so I ended up enabling wrap to fix the empty item scroll but I still end up getting the error message even though it doesn't seem to affect anything.

#1
Well, after some fiddling around I found that the module works fine when passing an argument through the url but when I try to use any version of viewfield I get the division by zero error above. If I use 5x-1.2 the carousel will show up and work fine but I get the error message. If I use the latest CVS (which supposedly has new view handling) the carousel will show up in preview but on the actual page I get this error:
viewsCarousel.carousel.views has no propertieshttp://www.projectumbrella.net/sites/all/modules/views_carousel/views_carousel.js
Line 86
viewsCarousel.carousel.views has no propertiesautoAttach()views_carousel.js (line 86)
e()jquery.js (line 2)
e()jquery.js (line 2)
e([function(), function(), function(), 6 more...], function(), undefined)jquery.js (line 2)
e()jquery.js (line 2)
[Break on this error] viewsCarousel.carousel.views[view_name].args = args.join('/');
The problem is then I'm not sure which module is messing up but I assume it has something to do with yours since the other views work fine :).
Edit: Upon further testing I have found that using the views_get_view function to embed it in a page or block also returns the sql/divisoin my zero error which shows that the problem is most likely in the views_carousel code.
#2
This is a summary of all of my research below. I'll leave the paragraphs unedited since you may want to read them.
_________________________________________________________________________
Any ideas? I can't seem to get this module to work without a "Query was empty query" error although I see other people having success. Something else I noticed. If I specify an exact amount of nodes to appear I no longer get the division by zero error but still get the "Query was empty query" error, however if I set the nodes to appear to 0 (all available) I get the division by zero error along with the empty query error.
Edit: Another peculiarity. If I tell the amount of nodes to appear to be less than the nodes queried, it will not let me press arrows to scroll and give the empty query error. If I set it to a number equal to or larger it doesn't give me any errors on the page view. However, when I scroll it lets me scroll into empty space. That is for $type page or block, if I try to do the same settings, but set the $type to embed, I get the division by zero and empty query errors again. I really don't know much about the code end, but from my tests there appears to be some fundamental difference between the way the view is output as a page or embed, but my research only shows that the difference is that a page view renames the titles of the page. This seems to be part of why Viewfield isn't working properly since it tries to use an embedded view.
#3
There were actual several interacting errors here. This patch fixes:
* If $view->{'nodes_per_'. $type} is zero then you get Division By Zero in views_carousel_ahah()
* If the above is fixed and $view->{'nodes_per_'. $type} is zero then you get Division By Zero in pager_query() (because the views pager was enabled and passed in a $limit of zero)
* The Javascript was setting the wrong variable to the '/' joined argument array so the AHAH links were actually broken, causing Division By Zero errors even when arguments are present.
Should be pretty much ready to roll - but please give it a try!
#4
Committed
#5
Yay :) Thanks Grugnog2!
#6
Automatically closed -- issue fixed for two weeks with no activity.