Commit 9532a902 authored by andrei.dincu's avatar andrei.dincu

Issue #2249723 by andrei.dincu: Remove xmlsitemap from the start of the module variables

parent ae7e6b4a
xmlsitemap_rebuild_needed: false
xmlsitemap_regenerate_needed: true
xmlsitemap_minimum_lifetime: 0
xmlsitemap_generated_last: 0
xmlsitemap_xsl: 1
xmlsitemap_prefetch_aliases: 1
xmlsitemap_chunk_size: 'auto'
xmlsitemap_batch_limit: 100
xmlsitemap_path: 'xmlsitemap'
xmlsitemap_base_url: ''
xmlsitemap_developer_mode: 0
xmlsitemap_frontpage_priority: 1.0
xmlsitemap_frontpage_changefreq: 86400
xmlsitemap_lastmod_format: 'Y-m-d\TH:i\Z'
xmlsitemap_gz: false
rebuild_needed: false
regenerate_needed: true
minimum_lifetime: 0
generated_last: 0
xsl: 1
prefetch_aliases: 1
chunk_size: 'auto'
batch_limit: 100
path: 'xmlsitemap'
base_url: ''
developer_mode: 0
frontpage_priority: 1.0
frontpage_changefreq: 86400
lastmod_format: 'Y-m-d\TH:i\Z'
gz: false
clean_url: 0
cron_threshold_error: 1209600
cron_threshold_warning: 172800
xmlsitemap_regenerate_last: {}
xmlsitemap_custom_links: {}
xmlsitemap_priority_default: {}
xmlsitemap_languages: {}
xmlsitemap_max_chunks: {}
xmlsitemap_max_filesize: {}
\ No newline at end of file
regenerate_last: {}
custom_links: {}
priority_default: {}
languages: {}
max_chunks: {}
max_filesize: {}
\ No newline at end of file
......@@ -4,49 +4,49 @@ xmlsitemap.settings:
type: mapping
label: 'XMLSitemap settings'
mapping:
xmlsitemap_rebuild_needed:
rebuild_needed:
type: boolean
label: 'Sitemap rebuilt'
xmlsitemap_regenerate_needed:
regenerate_needed:
type: boolean
label: 'Regenerate files'
xmlsitemap_minimum_lifetime:
minimum_lifetime:
type: integer
label: 'Minumum lifetime of an xmlsitemap xml file'
xmlsitemap_generated_last:
generated_last:
type: integer
label: 'Last generated sitemap'
xmlsitemap_xsl:
xsl:
type: integer
label: 'Check XSL functionality'
xmlsitemap_prefetch_aliases:
prefetch_aliases:
type: integer
label: 'Decide to prefetch aliases'
xmlsitemap_chunk_size:
chunk_size:
type: string
label: 'Set chunk size'
xmlsitemap_batch_limit:
batch_limit:
type: integer
label: 'Set batch limit'
xmlsitemap_path:
path:
type: string
label: 'Path of the XML generated files'
xmlsitemap_base_url:
base_url:
type: string
label: 'URL for XML sitemap file'
xmlsitemap_developer_mode:
developer_mode:
type: integer
label: 'Check if is developer mode'
xmlsitemap_frontpage_priority:
frontpage_priority:
type: float
label: 'Priority of the frontpage'
xmlsitemap_frontpage_changefreq:
frontpage_changefreq:
type: integer
label: 'Change frequency for frontpage'
xmlsitemap_lastmod_format:
lastmod_format:
type: integer
label: 'Last modified xmlsitemap format'
xmlsitemap_gz:
gz:
type: boolean
label: 'Gz'
clean_url:
......@@ -58,22 +58,22 @@ xmlsitemap.settings:
cron_threshold_warning:
type: integer
label: 'Threshold warning for cron job'
xmlsitemap_regenerate_last:
regenerate_last:
type: undefined
label: 'Last regenerate xmlsitemap'
xmlsitemap_custom_links:
custom_links:
type: undefined
label: 'Custom links'
xmlsitemap_priority_default:
priority_default:
type: undefined
label: 'Default priority for a link'
xmlsitemap_languages:
languages:
type: mapping
label: 'Languages for xmlsitemap'
xmlsitemap_max_chunks:
max_chunks:
type: undefined
label: 'Max chunks'
xmlsitemap_max_filesize:
max_filesize:
type: undefined
label: 'Maximul size of xml file'
......@@ -103,23 +103,23 @@ function xmlsitemap_requirements($phase) {
$requirements['xmlsitemap_file_size']['description'] = $t('You have exceeded the maximum sitemap file size of @size. If possible, decrease the number of links per sitemap page.', array('@size' => format_size(XMLSITEMAP_MAX_SITEMAP_FILESIZE)));
$requirements['xmlsitemap_file_size']['severity'] = REQUIREMENT_ERROR;
}
elseif (!\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_developer_mode')) {
elseif (!\Drupal::config('xmlsitemap.settings')->get('developer_mode')) {
unset($requirements['xmlsitemap_file_size']);
}
// Check when the cached files were last generated.
$generated_last = \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_generated_last');
$generated_last = \Drupal::config('xmlsitemap.settings')->get('generated_last');
$generated_ago = REQUEST_TIME - $generated_last;
$requirements['xmlsitemap_generated'] = array(
'title' => $t('XML sitemap'),
'value' => $generated_last ? $t('Last attempted generation on !date (!interval ago).', array('!date' => format_date($generated_last, 'small'), '!interval' => format_interval($generated_ago))) : $t('Cached files have not been generated yet.'),
'severity' => REQUIREMENT_OK,
);
if (\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_rebuild_needed') && _xmlsitemap_rebuild_form_access()) {
if (\Drupal::config('xmlsitemap.settings')->get('rebuild_needed') && _xmlsitemap_rebuild_form_access()) {
$requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
$requirements['xmlsitemap_generated']['description'] = $t('The XML sitemap data is out of sync and needs to be <a href="@link-rebuild">completely rebuilt<a>.', array('@link-rebuild' => url('admin/config/search/xmlsitemap/rebuild')));
}
elseif (\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_regenerate_needed')) {
elseif (\Drupal::config('xmlsitemap.settings')->get('regenerate_needed')) {
if ($max_filesize == 0) {
// A maximum sitemap file size of 0 indicates an error in generation.
$requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
......@@ -316,8 +316,8 @@ function xmlsitemap_install() {
'type' => 'frontpage',
'id' => 0,
'loc' => '',
'priority' => \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_frontpage_priority'),
'changefreq' => \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_frontpage_changefreq'),
'priority' => \Drupal::config('xmlsitemap.settings')->get('frontpage_priority'),
'changefreq' => \Drupal::config('xmlsitemap.settings')->get('frontpage_changefreq'),
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
))
->execute();
......@@ -341,7 +341,7 @@ function xmlsitemap_enable() {
// Ensure the file cache directory is available and ready.
xmlsitemap_check_directory();
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
}
/**
......@@ -422,7 +422,7 @@ function xmlsitemap_update_6202() {
// Refresh the schema and load the module if it's disabled.
drupal_get_schema(NULL, TRUE);
if (module_exists('xmlsitemap_i18n') && $languages = \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_languages')) {
if (module_exists('xmlsitemap_i18n') && $languages = \Drupal::config('xmlsitemap.settings')->get('languages')) {
foreach ($languages as $language) {
$sitemap = new stdClass();
$sitemap->context = array('language' => $language);
......@@ -437,15 +437,15 @@ function xmlsitemap_update_6202() {
}
// Language variable is no longer needed, so go ahead and delete it.
\Drupal::config()->clear('xmlsitemap_languages');
\Drupal::config()->clear('languages');
// Ensure that the sitemaps will be refreshed on next cron.
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_generated_last', 0);
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('generated_last', 0);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
}
/**
* Convert the xmlsitemap_max_filesize variable to a max_filesize column
* Convert the max_filesize variable to a max_filesize column
* per-sitemap.
*/
function xmlsitemap_update_6203() {
......@@ -472,8 +472,8 @@ function xmlsitemap_update_6203() {
->execute();
}
\Drupal::config('xmlsitemap.settings')->clear('xmlsitemap_max_filesize');
\Drupal::config('xmlsitemap.settings')->clear('xmlsitemap_max_chunks');
\Drupal::config('xmlsitemap.settings')->clear('max_filesize');
\Drupal::config('xmlsitemap.settings')->clear('max_chunks');
}
/**
......@@ -520,7 +520,7 @@ function xmlsitemap_update_7201() {
}
/**
* Convert the xmlsitemap_max_filesize variable to a max_filesize column
* Convert the max_filesize variable to a max_filesize column
* per-sitemap.
*/
function xmlsitemap_update_7202() {
......
......@@ -232,13 +232,13 @@ function _xmlsitemap_rebuild_form_access() {
*/
function xmlsitemap_cron() {
// If there were no new or changed links, skip.
if (!\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_regenerate_needed')) {
if (!\Drupal::config('xmlsitemap.settings')->get('regenerate_needed')) {
return;
}
// If the minimum sitemap lifetime hasn't been passed, skip.
$lifetime = REQUEST_TIME - \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_generated_last');
if ($lifetime < \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_minimum_lifetime')) {
$lifetime = REQUEST_TIME - \Drupal::config('xmlsitemap.settings')->get('generated_last');
if ($lifetime < \Drupal::config('xmlsitemap.settings')->get('minimum_lifetine')) {
return;
}
......@@ -276,28 +276,28 @@ function xmlsitemap_robotstxt() {
*/
function xmlsitemap_variables() {
return array(
'xmlsitemap_rebuild_needed' => FALSE,
'xmlsitemap_regenerate_needed' => FALSE,
'xmlsitemap_minimum_lifetime' => 0,
'xmlsitemap_generated_last' => 0,
'xmlsitemap_xsl' => 1,
'xmlsitemap_prefetch_aliases' => 1,
'xmlsitemap_chunk_size' => 'auto',
'xmlsitemap_batch_limit' => 100,
'xmlsitemap_path' => 'xmlsitemap',
'xmlsitemap_base_url' => $GLOBALS['base_url'],
'xmlsitemap_developer_mode' => 0,
'xmlsitemap_frontpage_priority' => 1.0,
'xmlsitemap_frontpage_changefreq' => XMLSITEMAP_FREQUENCY_DAILY,
'xmlsitemap_lastmod_format' => XMLSITEMAP_LASTMOD_MEDIUM,
'xmlsitemap_gz' => FALSE,
'rebuild_needed' => FALSE,
'regenerate_needed' => FALSE,
'minimum_lifetine' => 0,
'generated_last' => 0,
'xsl' => 1,
'prefetch_aliases' => 1,
'chunk_size' => 'auto',
'batch_limit' => 100,
'path' => 'xmlsitemap',
'base_url' => $GLOBALS['base_url'],
'developer_mode' => 0,
'frontpage_priority' => 1.0,
'frontpage_changefreq' => XMLSITEMAP_FREQUENCY_DAILY,
'lastmod_format' => XMLSITEMAP_LASTMOD_MEDIUM,
'gz' => FALSE,
// Removed variables are set to NULL so they can still be deleted.
'xmlsitemap_regenerate_last' => NULL,
'xmlsitemap_custom_links' => NULL,
'xmlsitemap_priority_default' => NULL,
'xmlsitemap_languages' => NULL,
'xmlsitemap_max_chunks' => NULL,
'xmlsitemap_max_filesize' => NULL,
'regenerate_last' => NULL,
'custom_links' => NULL,
'priority_default' => NULL,
'languages' => NULL,
'max_chunks' => NULL,
'max_filesize' => NULL,
);
}
......@@ -424,7 +424,7 @@ function xmlsitemap_sitemap_save(stdClass $sitemap) {
->execute();
// Mark the sitemaps as needing regeneration.
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
}
if ($sitemap->is_new) {
......@@ -593,7 +593,7 @@ function xmlsitemap_link_save(array $link) {
$existing = db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id", 0, 1, array(':type' => $link['type'], ':id' => $link['id']))->fetchAssoc();
// Check if this is a changed link and set the regenerate flag if necessary.
if (!\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_regenerate_needed')) {
if (!\Drupal::config('xmlsitemap.settings')->get('regenerate_needed')) {
_xmlsitemap_check_changed_link($link, $existing, TRUE);
}
......@@ -626,7 +626,7 @@ function xmlsitemap_link_save(array $link) {
function xmlsitemap_link_update_multiple($updates = array(), $conditions = array(), $check_flag = TRUE) {
// If we are going to modify a visible sitemap link, we will need to set
// the regenerate needed flag.
if ($check_flag && !\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_regenerate_needed')) {
if ($check_flag && !\Drupal::config('xmlsitemap.settings')->get('regenerate_needed')) {
_xmlsitemap_check_changed_links($conditions, $updates, TRUE);
}
......@@ -679,7 +679,7 @@ function xmlsitemap_link_delete_multiple(array $conditions) {
return FALSE;
}
if (!\Drupal::config('xmlsitemap.settings')->get('xmlsitemap_regenerate_needed')) {
if (!\Drupal::config('xmlsitemap.settings')->get('regenerate_needed')) {
_xmlsitemap_check_changed_links($conditions, array(), TRUE);
}
......@@ -718,7 +718,7 @@ function _xmlsitemap_check_changed_links(array $conditions = array(), array $upd
$changed = $query->execute()->fetchField();
if ($changed && $flag) {
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
}
return $changed;
......@@ -765,7 +765,7 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla
}
if ($changed && $flag) {
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
}
return $changed;
......@@ -779,7 +779,7 @@ function xmlsitemap_get_directory(stdClass $sitemap = NULL) {
$directory = &drupal_static(__FUNCTION__);
if (!isset($directory)) {
$directory = \Drupal::config('xmlsitemap.settings')->get('xmlsitemap_path');
$directory = \Drupal::config('xmlsitemap.settings')->get('path');
}
if (!empty($sitemap->smid)) {
......@@ -1257,7 +1257,7 @@ function xmlsitemap_form_submit_flag_regenerate($form, $form_state) {
$value = array_keys(array_filter($value));
}
if ($stored_value != 'not_a_variable' && $stored_value != $value) {
\Drupal::config('xmlsitemap.settings')->set('xmlsitemap_regenerate_needed', TRUE);
\Drupal::config('xmlsitemap.settings')->set('regenerate_needed', TRUE);
drupal_set_message(t('XML sitemap settings have been modified and the files should be regenerated. You can <a href="@run-cron">run cron manually</a> to regenerate the cached files.', array('@run-cron' => url('admin/reports/status/run-cron', array('query' => drupal_get_destination())))), 'warning', FALSE);
return;
}
......
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