mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-29 17:48:15 +08:00
Fix #20191: Fix ActiveRecord::getDirtyAttributes() for JSON columns with multi-dimensional array values
This commit is contained in:
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.51 under development
|
||||
------------------------
|
||||
|
||||
- Bug #20191: Fix `ActiveRecord::getDirtyAttributes()` for JSON columns with multi-dimensional array values (brandonkelly)
|
||||
- Bug #20175: Fix bad result for pagination when used with GridView (@lav45)
|
||||
|
||||
|
||||
|
||||
@ -1781,9 +1781,15 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
*/
|
||||
private function isValueDifferent($newValue, $oldValue)
|
||||
{
|
||||
if (is_array($newValue) && is_array($oldValue) && ArrayHelper::isAssociative($oldValue)) {
|
||||
$newValue = ArrayHelper::recursiveSort($newValue);
|
||||
$oldValue = ArrayHelper::recursiveSort($oldValue);
|
||||
if (is_array($newValue) && is_array($oldValue)) {
|
||||
// Only sort associative arrays
|
||||
$sorter = function(&$array) {
|
||||
if (ArrayHelper::isAssociative($array)) {
|
||||
ksort($array);
|
||||
}
|
||||
};
|
||||
$newValue = ArrayHelper::recursiveSort($newValue, $sorter);
|
||||
$oldValue = ArrayHelper::recursiveSort($oldValue, $sorter);
|
||||
}
|
||||
|
||||
return $newValue !== $oldValue;
|
||||
|
||||
Reference in New Issue
Block a user