Commit 16be96a5 authored by amateescu's avatar amateescu Committed by juampynr

Issue #2387331 by amateescu, Dave Reid, acrosman: Make it possible to disable...

Issue #2387331 by amateescu, Dave Reid, acrosman: Make it possible to disable cron generation of sitemaps and only use Drush
parent 39ae9758
......@@ -11,3 +11,4 @@ gz: false
clean_url: 0
cron_threshold_error: 1209600
cron_threshold_warning: 172800
disable_cron_regeneration: false
......@@ -43,6 +43,9 @@ xmlsitemap.settings:
cron_threshold_warning:
type: integer
label: 'Threshold warning for cron job'
disable_cron_regeneration:
type: boolean
label: 'Disable cron generation of sitemap files'
xmlsitemap.*:
type: config_entity
......
......@@ -186,6 +186,13 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
'#default_value' => $this->state->get('xmlsitemap_developer_mode'),
);
$form['advanced']['disable_cron_regeneration'] = array(
'#type' => 'checkbox',
'#title' => t('Disable cron generation of sitemap files.'),
'#default_value' => $config->get('disable_cron_regeneration'),
'#description' => t('This can be disabled if other methods are being used to generate the sitemap files, like %drush_regenerate.', ['%drush_regenerate' => 'drush xmlsitemap-regenerate']),
);
$form['xmlsitemap_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 20,
......
......@@ -171,6 +171,11 @@ function _xmlsitemap_rebuild_form_access() {
* @todo Regenerate one at a time?
*/
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;
......@@ -230,6 +235,7 @@ function xmlsitemap_config_variables() {
'frontpage_changefreq' => XMLSITEMAP_FREQUENCY_DAILY,
'lastmod_format' => XMLSITEMAP_LASTMOD_MEDIUM,
'gz' => FALSE,
'disable_cron_regeneration' => FALSE,
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment