diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1c25b67..2f1341c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -186,6 +186,13 @@ * Optimization: Initialize debugbar only after the configuration has been loaded * Optimization: Combine some early Grav processors into a single one +# v1.6.18 +## mm/dd/2019 + +1. [](#bugfix) + * Fixed fatal error when `$page->id()` is null [#2731](https://github.com/getgrav/grav/pull/2731) + * Fixed cache conflicts on pages with no set id + # v1.6.17 ## 11/06/2019 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 8d030981a..6fa0ad619 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -664,7 +664,7 @@ class Page implements PageInterface // Load cached content /** @var Cache $cache */ $cache = Grav::instance()['cache']; - $cache_id = md5('page' . $this->id()); + $cache_id = md5('page' . $this->getCacheKey()); $content_obj = $cache->fetch($cache_id); if (is_array($content_obj)) { @@ -870,7 +870,7 @@ class Page implements PageInterface public function cachePageContent() { $cache = Grav::instance()['cache']; - $cache_id = md5('page' . $this->id()); + $cache_id = md5('page' . $this->getCacheKey()); $cache->save($cache_id, ['content' => $this->content, 'content_meta' => $this->content_meta]); } @@ -1901,6 +1901,10 @@ class Page implements PageInterface */ public function id($var = null) { + if (null === $this->id) { + // We need to set unique id to avoid potential cache conflicts between pages. + $var = time() . md5($this->filePath()); + } if ($var !== null) { // store unique per language $active_lang = Grav::instance()['language']->getLanguage() ?: '';