From dae29d73d7375b43d87db7ce1d07363dde8fb320 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 14 Nov 2016 17:51:05 +0200 Subject: [PATCH] v.1.0.5 --- config/easy_xmlsitemap.settings.json | 1 - easy_xmlsitemap.admin.inc | 2 +- easy_xmlsitemap.info | 2 +- easy_xmlsitemap.install | 9 +++++++++ easy_xmlsitemap.module | 11 +++++------ 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config/easy_xmlsitemap.settings.json b/config/easy_xmlsitemap.settings.json index 4828266..096d156 100644 --- a/config/easy_xmlsitemap.settings.json +++ b/config/easy_xmlsitemap.settings.json @@ -3,7 +3,6 @@ "base_url": "", "sitemap_dir": "easy_xmlsitemap", "rebuild_frequency": "daily", - "last_build_date": 0, "excluded_urls": "", "excluded_langs": [] } diff --git a/easy_xmlsitemap.admin.inc b/easy_xmlsitemap.admin.inc index 622bb09..0068c5d 100644 --- a/easy_xmlsitemap.admin.inc +++ b/easy_xmlsitemap.admin.inc @@ -12,7 +12,7 @@ */ function easy_xmlsitemap_settings_form() { $config = config('easy_xmlsitemap.settings'); - $last_build_date = $config->get('last_build_date'); + $last_build_date = state_get('easy_xmlsitemap_last_build_date', 0); $info = $last_build_date != 0 ? t('Sitemap last build time: ') . format_date($last_build_date, 'short') diff --git a/easy_xmlsitemap.info b/easy_xmlsitemap.info index 32760c0..fea6382 100644 --- a/easy_xmlsitemap.info +++ b/easy_xmlsitemap.info @@ -4,5 +4,5 @@ package = SEO backdrop = 1.x type = module configure = admin/config/search/easy_xmlsitemap -version = 1.0.4 +version = 1.0.5 diff --git a/easy_xmlsitemap.install b/easy_xmlsitemap.install index 54f2321..4f4010f 100644 --- a/easy_xmlsitemap.install +++ b/easy_xmlsitemap.install @@ -36,3 +36,12 @@ function easy_xmlsitemap_update_1000() { $config->set('excluded_langs', array()); $config->save(); } + +/** + * Remove obsolete variable from config. + */ +function easy_xmlsitemap_update_1001() { + $config = config('easy_xmlsitemap.settings'); + $config->clear('last_build_date'); + $config->save(); +} diff --git a/easy_xmlsitemap.module b/easy_xmlsitemap.module index ea4faf8..e92a50a 100644 --- a/easy_xmlsitemap.module +++ b/easy_xmlsitemap.module @@ -106,11 +106,11 @@ function easy_xmlsitemap_build() { $output = "\n" . ""; + $frontpage_nid = easy_xmlsitemap_get_frontpage_nid(); + foreach ($result as $node) { if (node_access('view', $node, $account)) { // skip node if set as frontpage - $frontpage_nid = easy_xmlsitemap_get_frontpage_nid(); - if (!empty($frontpage_nid) && $node->nid == $frontpage_nid) { continue; } @@ -358,8 +358,7 @@ function easy_xmlsitemap_file_save($content) { $success = file_exists($file_path); if ($success) { - $config->set('last_build_date', time()); - $config->save(); + state_set('easy_xmlsitemap_last_build_date', time()); watchdog('easy_xmlsitemap', 'Sitemap file saved.'); backdrop_set_message(t('File "sitemap.xml" has been saved successfully.')); } @@ -374,7 +373,7 @@ function easy_xmlsitemap_output() { $config = config('easy_xmlsitemap.settings'); $file_dir = 'public://' . $config->get('sitemap_dir'); $file_path = $file_dir . '/' . 'sitemap.xml'; - $last_build_date = $config->get('last_build_date'); + $last_build_date = state_get('easy_xmlsitemap_last_build_date', 0); if (!file_exists($file_path) || !is_readable($file_path)) { return backdrop_not_found(); @@ -414,7 +413,7 @@ function easy_xmlsitemap_textarea_to_array($raw_string = '') { */ function easy_xmlsitemap_cron() { $config = config('easy_xmlsitemap.settings'); - $last_build_date = $config->get('last_build_date'); + $last_build_date = state_get('easy_xmlsitemap_last_build_date', 0); $rebuild_frequency = $config->get('rebuild_frequency'); if ($rebuild_frequency == 'manually') {