mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Optimize _clearCache().
It is cheaper to make an assignment or call strtolower() than to pluralize.
This commit is contained in:
parent
43fccc1cbf
commit
6dcfd28600
1 changed files with 14 additions and 10 deletions
|
@ -3669,25 +3669,29 @@ class Model extends Object implements CakeEventListener {
|
||||||
*
|
*
|
||||||
* @param string $type If null this deletes cached views if Cache.check is true
|
* @param string $type If null this deletes cached views if Cache.check is true
|
||||||
* Will be used to allow deleting query cache also
|
* Will be used to allow deleting query cache also
|
||||||
* @return boolean true on delete
|
* @return mixed True on delete, null otherwise
|
||||||
*/
|
*/
|
||||||
protected function _clearCache($type = null) {
|
protected function _clearCache($type = null) {
|
||||||
if ($type !== null || Configure::read('Cache.check') !== true) {
|
if ($type !== null || Configure::read('Cache.check') !== true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$assoc[] = strtolower(Inflector::pluralize($this->alias));
|
$pluralized = Inflector::pluralize($this->alias);
|
||||||
$assoc[] = Inflector::underscore(Inflector::pluralize($this->alias));
|
$assoc = array(
|
||||||
|
strtolower($pluralized),
|
||||||
|
Inflector::underscore($pluralized)
|
||||||
|
);
|
||||||
foreach ($this->_associations as $association) {
|
foreach ($this->_associations as $association) {
|
||||||
foreach ($this->$association as $className) {
|
foreach ($this->{$association} as $className) {
|
||||||
$pluralized = strtolower(Inflector::pluralize($className['className']));
|
$pluralizedAssociation = Inflector::pluralize($className['className']);
|
||||||
if (!in_array($pluralized, $assoc)) {
|
if (!in_array(strtolower($pluralizedAssociation), $assoc)) {
|
||||||
$assoc[] = $pluralized;
|
$assoc = array_merge($assoc, array(
|
||||||
$assoc[] = Inflector::underscore(Inflector::pluralize($className['className']));
|
strtolower($pluralizedAssociation),
|
||||||
|
Inflector::underscore($pluralizedAssociation)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$assoc = array_unique($assoc);
|
clearCache(array_unique($assoc));
|
||||||
clearCache($assoc);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue