Added option to disable SimpleCache key validation

This commit is contained in:
Matias Griese 2018-08-07 22:30:45 +03:00
parent 424da520cf
commit ef55e7d219
2 changed files with 19 additions and 9 deletions

View File

@ -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)

View File

@ -16,21 +16,18 @@ use Grav\Framework\Cache\Exception\InvalidArgumentException;
*/
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 @@ trait CacheTrait
$this->miss = new \stdClass;
}
/**
* @param $validation
*/
public function setValidation($validation)
{
$this->validation = (bool) $validation;
}
/**
* @return string
*/
@ -307,6 +312,10 @@ trait CacheTrait
*/
protected function validateKeys($keys)
{
if (!$this->validation) {
return;
}
foreach ($keys as $key) {
$this->validateKey($key);
}