Skip to content

Commit

Permalink
Added option to disable SimpleCache key validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Aug 7, 2018
1 parent 424da52 commit ef55e7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 18 additions & 9 deletions system/src/Grav/Framework/Cache/CacheTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
*/
Expand Down Expand Up @@ -307,6 +312,10 @@ protected function validateKey($key)
*/
protected function validateKeys($keys)
{
if (!$this->validation) {
return;
}

foreach ($keys as $key) {
$this->validateKey($key);
}
Expand Down

0 comments on commit ef55e7d

Please sign in to comment.