diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index d3592b3895..9c2de6886f 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -66,6 +66,9 @@ public function init(Grav $grav) $this->key = substr(md5(($prefix ? $prefix : 'g') . $uri->rootUrl(true) . $this->config->key . GRAV_VERSION), 2, 8); $this->driver = $this->getCacheDriver(); + + // Set the cache namespace to our unique key + $this->driver->setNamespace($this->key); } /** @@ -132,7 +135,6 @@ public function getCacheDriver() public function fetch($id) { if ($this->enabled) { - $id = $this->key . $id; return $this->driver->fetch($id); } else { return false; @@ -149,7 +151,6 @@ public function fetch($id) public function save($id, $data, $lifetime = null) { if ($this->enabled) { - $id = $this->key . $id; $this->driver->save($id, $data, $lifetime); } } diff --git a/system/src/Grav/Common/Filesystem/Folder.php b/system/src/Grav/Common/Filesystem/Folder.php index 8e7b896376..6c01b04a54 100644 --- a/system/src/Grav/Common/Filesystem/Folder.php +++ b/system/src/Grav/Common/Filesystem/Folder.php @@ -56,7 +56,6 @@ public static function lastModifiedFile($path) } } - return $last_modified; } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 63ebc11521..b1c97f80c6 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -106,7 +106,7 @@ public function __construct($array = array()) public function init($file) { $this->filePath($file->getPathName()); - $this->modified(filemtime($file->getPath())); + $this->modified($file->getMTime()); $this->id($this->modified().md5($this->filePath())); $this->header(); $this->slug(); diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index cd13a89b9c..39a201d7af 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -426,10 +426,17 @@ protected function recurse($directory = PAGES_DIR, Page &$parent = null) throw new \RuntimeException('Fatal error when creating page instances.'); } + $last_modified = 0; + /** @var \DirectoryIterator $file */ foreach ($iterator as $file) { $name = $file->getFilename(); + $date = $file->getMTime(); + if ($date > $last_modified) { + $last_modified = $date; + } + if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) { $page->init($file); @@ -465,8 +472,14 @@ protected function recurse($directory = PAGES_DIR, Page &$parent = null) $this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page])); } } + } + // Override the modified and ID so that it takes the latest change + // into account + $page->modified($last_modified); + $page->id($last_modified.md5($page->filePath())); + // Sort based on Defaults or Page Overridden sort order $this->children[$page->path()] = $this->sort($page);