diff --git a/core/lib/Drupal/Component/Utility/diffArray.php b/core/lib/Drupal/Component/Utility/diffArray.php index d374e10..0414001 100644 --- a/core/lib/Drupal/Component/Utility/diffArray.php +++ b/core/lib/Drupal/Component/Utility/diffArray.php @@ -15,7 +15,10 @@ class diffArray { /** * Computes the difference between arrays. * - * This is a PHP 5.4 safe version of array_diff_assoc(). + * This function is the same as array_diff_assoc(): compares array1 against + * array2 and returns the difference. However, while array_diff_assoc + * considers key => value1 and key => value2 the same if (string) $value1 === + * (string) $value2. * * @param array $array1 * The array to compare from. @@ -30,7 +33,7 @@ public static function diffAssoc(array $array1, array $array2) { $difference = array(); foreach ($array1 as $key => $value) { - if (!array_key_exists($key, $array2) || $array2[$key] !== $value) { + if (!array_key_exists($key, $array2) || ((string) $array2[$key] !== (string) $value)) { $difference[$key] = $value; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/diffArrayUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/diffArrayUnitTest.php index a983955..02e85bb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/diffArrayUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/diffArrayUnitTest.php @@ -65,9 +65,6 @@ function setUp() { public function testDiffAssoc() { $expected = array( 'different' => 'no', - 'int_diff' => 1, - // The whole value will be copied. - 'array_diff' => array('same' => 'same', 'array' => array('same' => 'same')), 'new' => 'new', );