diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d01d354e2..64af28d09a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 1. [](#new) * Added `Uri::method()` to get current HTTP method (GET/POST etc) * `FormatterInterface`: Added `getSupportedFileExtensions()` and `getDefaultFileExtension()` methods + * Added option to disable `SimpleCache` key validation 1. [](#improved) * Improved `Utils::url()` to support query strings 1. [](#bugfix) diff --git a/system/src/Grav/Framework/Cache/CacheTrait.php b/system/src/Grav/Framework/Cache/CacheTrait.php index 65f4d8d40b..2f2b178baa 100644 --- a/system/src/Grav/Framework/Cache/CacheTrait.php +++ b/system/src/Grav/Framework/Cache/CacheTrait.php @@ -16,21 +16,18 @@ */ trait CacheTrait { - /** - * @var string - */ + /** @var string */ private $namespace = ''; - /** - * @var int|null - */ + /** @var int|null */ private $defaultLifetime = null; - /** - * @var \stdClass - */ + /** @var \stdClass */ private $miss; + /** @var bool */ + private $validation = true; + /** * Always call from constructor. * @@ -45,6 +42,14 @@ protected function init($namespace = '', $defaultLifetime = null) $this->miss = new \stdClass; } + /** + * @param $validation + */ + public function setValidation($validation) + { + $this->validation = (bool) $validation; + } + /** * @return string */ @@ -307,6 +312,10 @@ protected function validateKey($key) */ protected function validateKeys($keys) { + if (!$this->validation) { + return; + } + foreach ($keys as $key) { $this->validateKey($key); }