Fix fatal error on deleting the homepage

This commit is contained in:
Flavio Copes
2015-08-07 12:05:34 +02:00
parent 79de53d310
commit fe8446aa08
2 changed files with 18 additions and 4 deletions

View File

@@ -148,7 +148,12 @@ class AdminPlugin extends Plugin
unset($this->grav['admin']->routes['/']);
}
$pages->dispatch('/', true)->route($home);
$page = $pages->dispatch('/', true);
// If page is null, the default page does not exist, and we cannot route to it
if ($page) {
$page->route($home);
}
// Make local copy of POST.
$post = !empty($_POST) ? $_POST : array();
@@ -216,9 +221,13 @@ class AdminPlugin extends Plugin
$twig->twig_vars['popularity'] = $this->popularity;
break;
case 'pages':
$twig->twig_vars['file'] = File::instance($this->admin->page(true)->filePath());
$twig->twig_vars['media_types'] = str_replace('defaults,', '',
implode(',.', array_keys($this->config->get('media'))));
$page = $this->admin->page(true);
if ($page != null) {
$twig->twig_vars['file'] = File::instance($page->filePath());
$twig->twig_vars['media_types'] = str_replace('defaults,', '',
implode(',.', array_keys($this->config->get('media'))));
}
break;
}
}