From 26838c70d018f4927dcf8de3cf7d5fdeb60684e6 Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Wed, 29 Jun 2016 13:58:07 -0300 Subject: [PATCH 1/2] BUGFIX: Fixed issue where classes not in the sitemap would cause a crash --- code/controllers/GoogleSitemapController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/GoogleSitemapController.php b/code/controllers/GoogleSitemapController.php index c84c860..db06e2e 100644 --- a/code/controllers/GoogleSitemapController.php +++ b/code/controllers/GoogleSitemapController.php @@ -60,7 +60,7 @@ class GoogleSitemapController extends Controller $class = $this->unsanitiseClassName($this->request->param('ID')); $page = $this->request->param('OtherID'); - if (GoogleSitemap::enabled() && $class && $page) { + if (GoogleSitemap::enabled() && $class && $page && ($class=='SiteTree' || GoogleSitemap::is_registered($class))) { Config::inst()->update('SSViewer', 'set_source_file_comments', false); $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"'); From cc0c20b3a8363a570b22c01d2c5a64c1d65cf2f9 Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Wed, 29 Jun 2016 14:48:51 -0300 Subject: [PATCH 2/2] Changed is_registered to check both the current case and lower case version of the class Fixed test failure resulting from GoogleSitemapRoute --- code/GoogleSitemap.php | 8 +++++++- code/controllers/GoogleSitemapController.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code/GoogleSitemap.php b/code/GoogleSitemap.php index f34a18b..025b4ce 100644 --- a/code/GoogleSitemap.php +++ b/code/GoogleSitemap.php @@ -118,7 +118,13 @@ class GoogleSitemap extends Object */ public static function is_registered($className) { - return isset(self::$dataobjects[$className]); + if (!isset(self::$dataobjects[$className])) { + $lowerKeys = array_change_key_case(self::$dataobjects); + + return isset($lowerKeys[$className]); + } + + return true; } /** diff --git a/code/controllers/GoogleSitemapController.php b/code/controllers/GoogleSitemapController.php index db06e2e..334c60b 100644 --- a/code/controllers/GoogleSitemapController.php +++ b/code/controllers/GoogleSitemapController.php @@ -60,7 +60,7 @@ class GoogleSitemapController extends Controller $class = $this->unsanitiseClassName($this->request->param('ID')); $page = $this->request->param('OtherID'); - if (GoogleSitemap::enabled() && $class && $page && ($class=='SiteTree' || GoogleSitemap::is_registered($class))) { + if (GoogleSitemap::enabled() && $class && $page && ($class == 'SiteTree' || $class == 'GoogleSitemapRoute' || GoogleSitemap::is_registered($class))) { Config::inst()->update('SSViewer', 'set_source_file_comments', false); $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');