Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save orakili/5351866 to your computer and use it in GitHub Desktop.

Select an option

Save orakili/5351866 to your computer and use it in GitHub Desktop.
Drupal XML sitemap cron background batch patch.
diff --git a/xmlsitemap.module b/xmlsitemap.module
index 93e935f..c48ac31 100644
--- a/xmlsitemap.module
+++ b/xmlsitemap.module
@@ -243,7 +243,16 @@ function xmlsitemap_cron() {
// Regenerate the sitemap XML files.
module_load_include('generate.inc', 'xmlsitemap');
- xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
+
+ // Try to launch the batch process in the background.
+ if (module_exists('background_batch')) {
+ $batch = xmlsitemap_regenerate_batch();
+ batch_set($batch);
+ background_batch_process_batch();
+ }
+ else {
+ xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
+ }
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment