function xmlsitemap_cron in XML sitemap 8
Same name and namespace in other branches
- 5.2 xmlsitemap/xmlsitemap.module \xmlsitemap_cron()
- 5 xmlsitemap.module \xmlsitemap_cron()
- 6.2 xmlsitemap.module \xmlsitemap_cron()
- 7.2 xmlsitemap.module \xmlsitemap_cron()
- 2.x xmlsitemap.module \xmlsitemap_cron()
Implements hook_cron().
@todo Use new Queue system. Need to add {sitemap}.queued. @todo Regenerate one at a time?
1 call to xmlsitemap_cron()
- XmlSitemapNodeFunctionalTest::testCron in tests/
src/ Functional/ XmlSitemapNodeFunctionalTest.php - Test the import of old nodes via cron.
File
- ./
xmlsitemap.module, line 182 - xmlsitemap XML sitemap
Code
function xmlsitemap_cron() {
// If cron sitemap file regeneration is disabled, stop.
if (\Drupal::config('xmlsitemap.settings')
->get('disable_cron_regeneration')) {
return;
}
// If there were no new or changed links, skip.
if (!\Drupal::state()
->get('xmlsitemap_regenerate_needed')) {
return;
}
// If the minimum sitemap lifetime hasn't been passed, skip.
$lifetime = \Drupal::time()
->getRequestTime() - \Drupal::state()
->get('xmlsitemap_generated_last');
if ($lifetime < \Drupal::config('xmlsitemap.settings')
->get('minimum_lifetime')) {
return;
}
xmlsitemap_xmlsitemap_index_links(\Drupal::config('xmlsitemap.settings')
->get('batch_limit'));
// Regenerate the sitemap XML files.
xmlsitemap_run_unprogressive_batch('xmlsitemap_regenerate_batch');
}