Closed (fixed)
Project:
XML sitemap
Version:
6.x-1.x-dev
Component:
xmlsitemap_node.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2009 at 06:43 UTC
Updated:
29 Jun 2009 at 04:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
avpadernoThis is a duplicate of #352046: Division by zero; see there for any informations.
The code should simply be
Comment #2
strikehawkecomm commentedMine is failing in sites/all/modules/xmlsitemap/xmlsitemap/xmlsitemap.module on line 313
It starts with:
So, why is the beta versions not alpha tested before released to be bug tested or is there something unique about my installation with no core changes?
Comment #3
strikehawkecomm commentedComment #4
dave reid@strikehawkecomm: Thanks for reporting this, I'll try and take a look at the versions code.
Comment #5
dave reidLine 313 is
$chunk_count = (integer) ($link_count / $chunk_size);.The variable $chunk_size comes directly from variable_get('xmlsitemap_chunk_size', 1000), but can also be set to a different value in some code just a little bit later:
If $link_count is 0 (for instance when the modules are first installed), then $chunk_size is going to be set to 0, leading to a division by zero on the next time this code is executed.
If the attached patch looks good, I'll commit this later today.
Comment #6
avpadernoThe value for the chunk size is changed when the number of chunks is greater than
1000, which means that the number of links must be at least1000001; in such case,$link_countis surely not 0.Comment #7
Anonymous (not verified) commentedDo we really need the variable_set in the hook_update_N? If we do then wouldn't we also need it for the hook_install?
Comment #8
avpadernoThe reported error is the division by zero, and who re-opened the issue pointed out that
(integer) ($link_count / $chunk_size)is the line causing the error. If this is the case, then the division by zero is caused by$chunk_sizebeing set to zero.The code, as also reported by strikehawkecomm in #2, would change the value for the chunk size only when the numbers of chunks is greater than 1000, which means that
$link_countmust be at least 1000001. In these case,$new_size = (integer) ceil($link_count / 100000) * 100would assign 1100 to$new_size. Changing the code from$new_size = (integer) ceil($link_count / 100000) * 100to$new_size = (integer) ceil(max($link_count, 1) / 100000) * 100doesn't change anything becausemax($link_count, 1), where$link_countis 1000001 will always use the value of$link_count.To me, it seems that the error is caused by the fact the variable
$chunk_sizehas a wrong value because the Drupal variable used to initialize it is set to 0 for some reasons; this is not necessarily caused by code executed in XML sitemap.Comment #9
avpadernoComment #10
Anonymous (not verified) commentedI need to review the current code base. This may become a duplicate of #485632: The code to automatically calculate the sitemap chunk size is wrong.
Comment #11
avpadernoThe code reported in the last comments doesn't even exist in the development snapshot, which uses different code.
Comment #12
avpadernoThe reported code doesn't exist anymore in the last commits done.
I would rather see this bug report as fixed.