Merge pull request #106 from webbuilders-group/not-allowed-block

BUGFIX: Fixed issue where classes not in the sitemap would cause a crash
This commit is contained in:
Will Rossiter 2016-06-30 08:46:15 +12:00 committed by GitHub
commit bb7fbb8308
2 changed files with 8 additions and 2 deletions

View File

@ -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;
}
/**

View File

@ -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' || $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"');