diff --git a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php index f4117d10fed0b48b60efb99264b5bebc5531b167..02e9a4f43b5144afd258726ad2786795dae54e67 100644 --- a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php +++ b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php @@ -59,8 +59,7 @@ public function autocomplete(Request $request) { $matches = array(); foreach ($this->blockManager->getCategories() as $category) { if (stripos($category, $typed_category) === 0) { - $category = String::checkPlain($category); - $matches[$category] = $category; + $matches[$category] = String::checkPlain($category); } } return new JsonResponse($matches); diff --git a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php index 14a3a1a5ac3ba01e26fed6dce6c9e5de9c937ef3..026ad5c7249134e1f9fb56aedf0ead7b4644224a 100644 --- a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php @@ -63,9 +63,9 @@ public function setUp() { public function testAutocompleteSuggestions($string, $suggestions) { $suggestions = array_map(function ($suggestion) { return String::checkPlain($suggestion); - }, $suggestions); + }, MapArray::copyValuesToKeys($suggestions)); $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string))); - $this->assertSame(MapArray::copyValuesToKeys($suggestions), json_decode($result->getContent(), TRUE)); + $this->assertSame($suggestions, json_decode($result->getContent(), TRUE)); } /**