From 0191a1d2865cfb80de269a5f4c29096588627518 Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sat, 22 Apr 2017 19:53:23 +0200 Subject: [PATCH 1/2] Add timestamp to configuration settings --- .../src/Grav/Common/Config/CompiledBase.php | 19 ++++++++++++++++++- .../src/Grav/Common/Config/CompiledConfig.php | 1 + .../Grav/Common/Config/CompiledLanguages.php | 1 + system/src/Grav/Common/Config/Config.php | 10 ++++++++++ system/src/Grav/Common/Config/Languages.php | 9 +++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Config/CompiledBase.php b/system/src/Grav/Common/Config/CompiledBase.php index e8ead86fde..8094a69a31 100644 --- a/system/src/Grav/Common/Config/CompiledBase.php +++ b/system/src/Grav/Common/Config/CompiledBase.php @@ -27,6 +27,11 @@ abstract class CompiledBase */ public $checksum; + /** + * @var string Timestamp of compiled configuration + */ + public $timestamp; + /** * @var string Cache folder to be used. */ @@ -59,9 +64,10 @@ public function __construct($cacheFolder, array $files, $path) throw new \BadMethodCallException('Cache folder not defined.'); } + $this->path = $path ? rtrim($path, '\\/') . '/' : ''; $this->cacheFolder = $cacheFolder; $this->files = $files; - $this->path = $path ? rtrim($path, '\\/') . '/' : ''; + $this->timestamp = 0; } /** @@ -84,6 +90,16 @@ public function name($name = null) */ public function modified() {} + /** + * Get timestamp of compiled configuration + * + * @return int Timestamp of compiled configuration + */ + public function timestamp() + { + return $this->timestamp ?: time(); + } + /** * Load the configuration. * @@ -196,6 +212,7 @@ protected function loadCompiledFile($filename) } $this->createObject($cache['data']); + $this->timestamp = isset($cache['timestamp']) ? $cache['timestamp'] : 0; $this->finalizeObject(); diff --git a/system/src/Grav/Common/Config/CompiledConfig.php b/system/src/Grav/Common/Config/CompiledConfig.php index 3b2e56fd48..966d18a42c 100644 --- a/system/src/Grav/Common/Config/CompiledConfig.php +++ b/system/src/Grav/Common/Config/CompiledConfig.php @@ -77,6 +77,7 @@ protected function createObject(array $data = []) protected function finalizeObject() { $this->object->checksum($this->checksum()); + $this->object->timestamp($this->timestamp()); } /** diff --git a/system/src/Grav/Common/Config/CompiledLanguages.php b/system/src/Grav/Common/Config/CompiledLanguages.php index f65641adfd..84385fd952 100644 --- a/system/src/Grav/Common/Config/CompiledLanguages.php +++ b/system/src/Grav/Common/Config/CompiledLanguages.php @@ -38,6 +38,7 @@ protected function createObject(array $data = []) protected function finalizeObject() { $this->object->checksum($this->checksum()); + $this->object->timestamp($this->timestamp()); } diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php index 160b936f52..23786191ce 100644 --- a/system/src/Grav/Common/Config/Config.php +++ b/system/src/Grav/Common/Config/Config.php @@ -17,6 +17,7 @@ class Config extends Data { protected $checksum; protected $modified = false; + protected $timestamp = 0; public function key() { @@ -41,6 +42,15 @@ public function modified($modified = null) return $this->modified; } + public function timestamp($timestamp = null) + { + if ($timestamp !== null) { + $this->timestamp = $timestamp; + } + + return $this->timestamp; + } + public function reload() { $grav = Grav::instance(); diff --git a/system/src/Grav/Common/Config/Languages.php b/system/src/Grav/Common/Config/Languages.php index 7ce4240f7e..1aa3543872 100644 --- a/system/src/Grav/Common/Config/Languages.php +++ b/system/src/Grav/Common/Config/Languages.php @@ -30,6 +30,15 @@ public function modified($modified = null) return $this->modified; } + public function timestamp($timestamp = null) + { + if ($timestamp !== null) { + $this->timestamp = $timestamp; + } + + return $this->timestamp; + } + public function reformat() { if (isset($this->items['plugins'])) { From 8a7a959453b07f394d827dcbb64e30aa003e7535 Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sat, 22 Apr 2017 19:56:38 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47439d9c60..acb6fd7a40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.2.4 ## 04/xx/2017 +1. [](#improved) + * Add timestamp to configuration settings [#1445](https://github.com/getgrav/grav/pull/1445) 1. [](#bugfix) * Allow multiple calls to `Themes::initTheme()` without throwing errors * Fixed querystrings in root pages with multi-lang enabled [#1436](https://github.com/getgrav/grav/issues/1436)