Fix #19804: Change $this->oldAttributes to $this->_oldAttributes to avoid calling a method unnecessarily

This commit is contained in:
Thiago Talma
2023-04-18 12:54:54 -03:00
committed by GitHub
parent 1a07bb14d9
commit 246a581637
2 changed files with 3 additions and 2 deletions

View File

@ -24,6 +24,7 @@ Yii Framework 2 Change Log
- Bug #19770: Fix `yii\mutex\MysqlMutex` `keyPrefix` expression param binding (kamarton)
- Enh #19794: Add caching in `yii\web\Request` for `getUserIP()` and `getSecureForwardedHeaderTrustedParts()` (rhertogh)
- Bug #19795: Fix `yii\web\Response::redirect()` to prevent setting headers with URL containing new line character (bizley)
- Enh #19804: Change `$this->oldAttributes` to `$this->_oldAttributes` to avoid calling a method unnecessarily (thiagotalma)
2.0.47 November 18, 2022
------------------------

View File

@ -1762,8 +1762,8 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*/
private function isAttributeDirty($attribute, $value)
{
$old_attribute = $this->oldAttributes[$attribute];
if (is_array($value) && is_array($this->oldAttributes[$attribute])) {
$old_attribute = $this->_oldAttributes === null || !array_key_exists($attribute, $this->_oldAttributes) ? [] : $this->_oldAttributes[$attribute];
if (is_array($value) && is_array($this->_oldAttributes[$attribute])) {
$value = ArrayHelper::recursiveSort($value);
$old_attribute = ArrayHelper::recursiveSort($old_attribute);
}