From e29d9821935fd96c679f9504737c8ee513c75fde Mon Sep 17 00:00:00 2001 From: KSP Date: Thu, 13 Aug 2020 10:50:53 +0200 Subject: [PATCH] Sort arrays so that different order of values doesn't trigger update Fields like e.g. Category fields will trigger an update and resave of the element if arrays are identical, but values come in different order. Sorting them should fix this. --- src/helpers/DataHelper.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/helpers/DataHelper.php b/src/helpers/DataHelper.php index b7ffa7e3..a19c1da1 100644 --- a/src/helpers/DataHelper.php +++ b/src/helpers/DataHelper.php @@ -174,6 +174,12 @@ public static function compareElementContent($content, $element) $newValue = null; } + // If arrays of values, sort them to help comparison + if (is_array($existingValue) && is_array($newValue)) { + sort($existingValue); + sort($newValue); + } + // Check for simple fields first if ($existingValue == $newValue) { unset($trackedChanges[$key]);