From a1ea841034667580dee1f1689a514d0ee203bd00 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 24 Oct 2019 13:59:00 +0300 Subject: [PATCH] Fixed fatal error in multi-site setups --- CHANGELOG.md | 3 ++- system/src/Grav/Common/Page/Pages.php | 18 ++++++++++++------ .../Common/Processors/InitializeProcessor.php | 5 +++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index beaae6789..34a31e92d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,8 +22,9 @@ * Fixed error on missing `Flex` templates in if `Flex Objects` plugin isn't installed * Fixed `PageTranslateTrait::getAllLanguages()` and `getAllLanguages()` to include default language * Fixed multi-language saving issues with default language in `Flex Pages` - * Grav 1.7: Fixed PHP 7.1 compatibility issues * Selfupgrade CLI: Fixed broken selfupgrade assets reference [#2681](https://github.com/getgrav/grav/issues/2681) + * Grav 1.7: Fixed PHP 7.1 compatibility issues + * Grav 1.7: Fixed fatal error in multi-site setups # v1.7.0-beta.10 ## 10/03/2019 diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 9a9e80e39..31f2ef266 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -99,11 +99,6 @@ class Pages public function __construct(Grav $grav) { $this->grav = $grav; - - $type = $grav['config']->get('system.pages.type'); - if ($type === 'flex') { - $this->initFlexPages(); - } } /** @@ -122,7 +117,7 @@ class Pages if (!$this->enable_pages) { $this->enable_pages = true; - $this->buildPages(); + $this->init(); } } @@ -247,6 +242,15 @@ class Pages $this->check_method = strtolower($method); } + public function register(): void + { + $config = $this->grav['config']; + $type = $config->get('system.pages.type'); + if ($type === 'flex') { + $this->initFlexPages(); + } + } + /** * Class initialization. Must be called before using this class. */ @@ -256,6 +260,8 @@ class Pages return; } + $this->initialized = true; + $config = $this->grav['config']; $this->ignore_files = $config->get('system.pages.ignore_files'); $this->ignore_folders = $config->get('system.pages.ignore_folders'); diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php index 008ff1316..3776efc3b 100644 --- a/system/src/Grav/Common/Processors/InitializeProcessor.php +++ b/system/src/Grav/Common/Processors/InitializeProcessor.php @@ -11,6 +11,7 @@ namespace Grav\Common\Processors; use Grav\Common\Config\Config; use Grav\Common\Debugger; +use Grav\Common\Page\Pages; use Grav\Common\Uri; use Grav\Common\Utils; use Grav\Framework\Psr7\Response; @@ -137,6 +138,10 @@ class InitializeProcessor extends ProcessorBase date_default_timezone_set($timezone); } + /** @var Pages $pages */ + $pages = $this->container['pages']; + $pages->register(); + /** @var Uri $uri */ $uri = $this->container['uri']; $uri->init();