diff --git a/core/modules/ckeditor5/src/HTMLRestrictions.php b/core/modules/ckeditor5/src/HTMLRestrictions.php index 3a2d7e886c5..25503760afc 100644 --- a/core/modules/ckeditor5/src/HTMLRestrictions.php +++ b/core/modules/ckeditor5/src/HTMLRestrictions.php @@ -768,8 +768,11 @@ final class HTMLRestrictions { } // Make sure the order of the union array matches the order of the keys in // the arrays provided. - $keys_order = array_merge($array1_keys, $array2_keys); - return array_merge(array_flip($keys_order), $union); + $ordered = []; + foreach (array_merge($array1_keys, $array2_keys) as $key) { + $ordered[$key] = $union[$key]; + } + return $ordered; } /** diff --git a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php index dec20207f26..41179261df8 100644 --- a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php +++ b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php @@ -997,6 +997,13 @@ class HTMLRestrictionsTest extends UnitTestCase { 'intersection' => 'a', 'union' => 'b', ]; + yield 'attribute restrictions are the same:
    vs
      ' => [ + 'a' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]), + 'b' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]), + 'diff' => HTMLRestrictions::emptySet(), + 'intersection' => 'a', + 'union' => 'a', + ]; // Complex cases. yield 'attribute restrictions are different: vs ' => [