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

Kripsy - March 6, 2008 - 00:33

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 properties
http://www.projectumbrella.net/sites/all/modules/views_carousel/views_carousel.js
Line 86

viewsCarousel.carousel.views has no properties
autoAttach()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

Kripsy - March 23, 2008 - 05:50

This is a summary of all of my research below. I'll leave the paragraphs unedited since you may want to read them.

  • Page View: If the amount of nodes to appear is set to less than the nodes being queried the carousel is unscrollable and returns a "Query was empty query" error. If the amount of nodes present is set to 0 (all available) the empty query and Division by Zero errors returned. If the amount of nodes present is set to a number larger than the number of nodes queried (it doesn't matter how much larger), no errors are returned, but you are allowed to scroll into empty space. I found that if I scrolled up to the last object, back one, and then forward again the arrow would dim out as it should. To fix this I simply turned on the cycle option so it would scroll back to the first item instead of empty space.
  • Block View: Same as page view.
  • Embed View: No matter the settings, at least one empty query and division by zero error is reported (multiple for each time I try to scroll a blank object -- I assume this has to do with the caching). This is what gives me trouble. There is something different about how the view is handled through page/block and embed that generates an error every time.
  • _________________________________________________________________________

    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

    Grugnog2 - June 17, 2008 - 00:46
    Priority:normal» critical
    Status:active» patch (code needs review)

    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!

    AttachmentSize
    228937.patch2.14 KB

    #4

    Grugnog2 - July 29, 2008 - 21:19
    Status:patch (code needs review)» fixed

    Committed

    #5

    Wim Leers - July 29, 2008 - 21:45

    Yay :) Thanks Grugnog2!

    #6

    Anonymous (not verified) - August 12, 2008 - 21:53
    Status:fixed» closed

    Automatically closed -- issue fixed for two weeks with no activity.

     
     

    Drupal is a registered trademark of Dries Buytaert.