- 🇺🇸United States smustgrave
Needs a reroll but appears to be dead code maybe?
- Status changed to RTBC
over 2 years ago 6:42pm 28 January 2023 - 🇺🇸United States smustgrave
Pretty convinced this is deadcode but will see what the committers say.
- Status changed to Needs work
over 2 years ago 10:17am 8 February 2023 - 🇳🇿New Zealand quietone
The route 'user.autocomplete' was removed in Drupal 8.0.x #2434697: Remove UserAutocompleteController → .
There is another instance of the string 'user/autocomplete'. That should be investigated here as well.
$ git grep 'user.autocomplete' | grep -v drupal[6-7].php core/modules/node/tests/src/Functional/NodeCreationTest.php: $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-uid-0-value" and contains(@data-autocomplete-path, "user/autocomplete")]'); core/modules/system/tests/src/Functional/Theme/FastTest.php: $this->drupalGet('user/autocomplete', ['query' => ['q' => $this->account->getAccountName()]]);
- First commit to issue fork.
- 🇦🇺Australia mstrelan
#22 - The other reference to
user/autocomplete
was removed in 🐛 NodeCreationtest::testAuthorAutocomplete has incorrect selector for falsey check ActiveI've created an MR to remove the test. But kind of agree with #17:
What was this originally testing? Should we still test that?
Good question. The test was meant to ensure that the theme registry was not initialized when making a request to the autocomplete route. The
theme_test
module has an event subscriber that throws a "registry initialized" exception if the theme registry is initialized. This currently only applies to the'system.entity_autocomplete'
route but previously applied to'user.autocomplete'
and'user.autocomplete_anonymous'
, before #2434697: Remove UserAutocompleteController → . I'm not sure if there is any test that's checking for that exception, so perhaps that should be removed too? Or we refactor FastTest to use the'system.entity_autocomplete'
route instead. - 🇦🇺Australia mstrelan
I did some more digging. We can use
'system.entity_autocomplete'
in the test like so:$this->drupalLogin($this->account); $selection_settings_key = Crypt::hmacBase64(serialize([]) . 'userdefault', Settings::getHashSalt());; \Drupal::keyValue('entity_autocomplete')->set($selection_settings_key, []); $this->drupalGet('/entity_reference_autocomplete/user/default/' . $selection_settings_key, [ 'query' => [ 'q' => $this->account->getAccountName(), ], ]);
However we never enter
ThemeTestSubscriber::onView
so the exception is never thrown anyway.I think we can just remove the test.
- 🇺🇸United States smustgrave
Thanks @mstrelan for digging into that! Agree with your findings.
- 🇬🇧United Kingdom catch
The theme_test module has an event subscriber that throws a "registry initialized" exception if the theme registry is initialized.
Does that event subscriber also need to be removed from theme_test module then?
- 🇦🇺Australia mstrelan
Removed the onView part of the event subscriber. Adding a related issue too.
- First commit to issue fork.
- 🇬🇧United Kingdom catch
I think the overall assessment that this test never worked, can't test what it's trying to and should just go makes sense. Maybe we theoretically might have some test coverage missing, but that's already been the case for several years and we'd need to start writing the test again from scratch, in which case the current test does not help with that. Committed/pushed to 11.x, thanks!