As last step of installing site with custom installation profile I trying to rebuild xmlsitemap with xmlsitemap_rebuild_batch function. Everything work great but after adding some translation modules started appearing this error.
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: ../install.php?profile=fred&locale=en&id=2&op=do StatusText: Service unavailable (with message) ResponseText: Recoverable fatal error: Argument 1 passed to xmlsitemap_menu_xmlsitemap_process_menu_links() must be an array, null given, called in ../sites/all/modules/contrib/xmlsitemap/xmlsitemap.generate.inc on line 456 and defined in xmlsitemap_menu_xmlsitemap_process_menu_links() (line 83 of...
After debugging this functions I found the problem. In function xmlsitemap_rebuild_batch_fetch when the function is called at first time in batch variable $context['sandbox']['max'] is set to count of entities in DB in my case it was 515 entities. Checked it also manualy and the number was correct. But after few cycles of batch I checked it one more time and now there were only 514 entities. This leads to error becouse the ending conditions was always false and $info['xmlsitemap']['process callback']($ids); was called with NULL parameter. I don't know what is causing the difference in count of entities but this situation is possible so I made this patch to fix this situation.

Comments

reeller_sk’s picture

Here is the patch file.

Anonymous’s picture

Status: Patch (to be ported) » Needs review

Status: Needs review » Needs work

The last submitted patch, xmlsitemap_xmlsitemap_rebuild_batch_fetch_fix_1902916.diff, failed testing.

Anonymous’s picture

You need to clone the git repository, checkout the 7.x-2.x branch, make your changes and then create the diff file.

reeller_sk’s picture

I'm sorry I didn't have time until now. So here is the patch based on 7.x-2.x branch. Added one more thing, after query execution i had case when result was empty so array_keys function caused warning parameter is not array.

Anonymous’s picture

Status: Needs work » Needs review

Here robot.

chris matthews’s picture

Version: 7.x-2.0-rc2 » 7.x-2.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch in #5 to xmlsitemap.generate.inc does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap.generate.inc...
error: while searching for:
  $query->range(0, $limit);

  $result = $query->execute();
  $ids = array_keys($result[$entity]);

  $info['xmlsitemap']['process callback']($ids);
  $context['sandbox']['last_id'] = end($ids);
  $context['sandbox']['progress'] += count($ids);
  $context['message'] = t('Now processing %entity @last_id (@progress of @count).', array('%entity' => $entity, '@last_id' => $context['sandbox']['last_id'], '@progress' => $context['sandbox']['progress'], '@count' => $context['sandbox']['max']));

  if ($context['sandbox']['progress'] >= $context['sandbox']['max']) {
    $context['finished'] = 1;
  }
  else {

error: patch failed: xmlsitemap.generate.inc:451
error: xmlsitemap.generate.inc: patch does not apply