mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Refactors Model::_clearCache
- don't use mixed keys in $assoc array - removes unnecessary strtolower on Inflector::underscore result - return early
This commit is contained in:
parent
99ec97bd19
commit
be61a5023f
1 changed files with 16 additions and 21 deletions
|
@ -3499,18 +3499,17 @@ class Model extends Object implements CakeEventListener {
|
|||
* @return boolean true on delete
|
||||
*/
|
||||
protected function _clearCache($type = null) {
|
||||
if ($type === null) {
|
||||
if (Configure::read('Cache.check') === true) {
|
||||
$pluralized = Inflector::pluralize($this->alias);
|
||||
$assoc[$this->alias] = strtolower($pluralized);
|
||||
$assoc[] = strtolower(Inflector::underscore($pluralized));
|
||||
if ($type !== null || Configure::read('Cache.check') !== true) {
|
||||
return;
|
||||
}
|
||||
$assoc[] = strtolower(Inflector::pluralize($this->alias));
|
||||
$assoc[] = Inflector::underscore(Inflector::pluralize($this->alias));
|
||||
foreach ($this->_associations as $association) {
|
||||
foreach ($this->$association as $associatedClass) {
|
||||
$className = $associatedClass['className'];
|
||||
if (!isset($assoc[$className])) {
|
||||
$pluralized = Inflector::pluralize($className);
|
||||
$assoc[$className] = strtolower($pluralized);
|
||||
$assoc[] = strtolower(Inflector::underscore($pluralized));
|
||||
foreach ($this->$association as $className) {
|
||||
$pluralized = strtolower(Inflector::pluralize($className['className']));
|
||||
if (!in_array($pluralized, $assoc)) {
|
||||
$assoc[] = $pluralized;
|
||||
$assoc[] = Inflector::underscore(Inflector::pluralize($className['className']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3518,10 +3517,6 @@ class Model extends Object implements CakeEventListener {
|
|||
clearCache($assoc);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
//Will use for query cache deleting
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of a model validator for this class
|
||||
|
|
Loading…
Reference in a new issue