Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp to configuration settings #1445

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 18 additions & 1 deletion system/src/Grav/Common/Config/CompiledBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ abstract class CompiledBase
*/
public $checksum;

/**
* @var string Timestamp of compiled configuration
*/
public $timestamp;

/**
* @var string Cache folder to be used.
*/
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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.
*
Expand Down Expand Up @@ -196,6 +212,7 @@ protected function loadCompiledFile($filename)
}

$this->createObject($cache['data']);
$this->timestamp = isset($cache['timestamp']) ? $cache['timestamp'] : 0;

$this->finalizeObject();

Expand Down
1 change: 1 addition & 0 deletions system/src/Grav/Common/Config/CompiledConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function createObject(array $data = [])
protected function finalizeObject()
{
$this->object->checksum($this->checksum());
$this->object->timestamp($this->timestamp());
}

/**
Expand Down
1 change: 1 addition & 0 deletions system/src/Grav/Common/Config/CompiledLanguages.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function createObject(array $data = [])
protected function finalizeObject()
{
$this->object->checksum($this->checksum());
$this->object->timestamp($this->timestamp());
}


Expand Down
10 changes: 10 additions & 0 deletions system/src/Grav/Common/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Config extends Data
{
protected $checksum;
protected $modified = false;
protected $timestamp = 0;

public function key()
{
Expand All @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions system/src/Grav/Common/Config/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down