Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
For modules which configuration page is not in a menu, the description of the "Configure" link is extracted using the title_resolver service.
If a custom module uses a "_title_callback" that uses a RouteMatchInterface object and/or if it relies on custom attributes given as default attributes in the route definition, the call to the title_resolver::getTitle() method throws a fatal error.
Proposed resolution
Instead of jumping through hoops to determine the page title for the given configure link:
<a title="really expensive to calculate title with lots of technical implications" href="some/url">Configure</a>
Add context in the form of the module name:
<a href="some/url">Configure<span class="visually-hidden">the {foobar} module</span></a>
Beta phase evaluation
Issue category | Bug because the current code can throw fatal errors, causing WSOD |
---|---|
Issue priority | Major because it has impacts on contrib but under rare circumstances |
Prioritized changes | Bug fix that improves a11y - prioritized |
Disruption | Not disruptive as Core does not use this for now |
User interface changes
Accessibility changes as outlined above.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#26 | interdiff.2527546.20.26.txt | 1.91 KB | DuaelFr |
#26 | modules_list_form_title_resolver_2527546-26.patch | 6.03 KB | DuaelFr |
#20 | interdiff.2527546.17.19.txt | 3.32 KB | DuaelFr |
#20 | modules_list_form_title_resolver_2527546-19.patch | 5.07 KB | DuaelFr |
#20 | fzXQMoVHFqo20qj9ifL4saGxo1_500.jpg | 47.28 KB | DuaelFr |
Comments
Comment #1
DuaelFrComment #2
dawehnerLooks right for me, but we need some tests, given its a bug :(
Comment #3
DuaelFrI'd need some help with that tests :/
Comment #4
DuaelFrLet's try this way.
Let me know if it's not enough.
Comment #7
DuaelFrTrying to improve the test I figured out that it would be more clever to extend the system_test module instead of adding something new in the module_test module.
Comment #10
chx CreditAttribution: chx commentedTo make it easier to read, the point of the patch is
$request->attributes->add($route_object->getDefaults());
this line, the rest is cleanup, replacing strings with constants (very nice cleanup!). So this makesbar: 'baz'
in the test pass.Comment #11
chx CreditAttribution: chx commentedPs. I am surprised this is still a thing that needs to happen despite #2124749: [meta] Stop using $request->attributes->get(MAGIC_KEY) as a public API . Someone in the know wants to explain? This shouldn't hold up the patch, the logic is clearly in HEAD already.
Comment #12
DuaelFrThis one is important too because '_route' is an incorrect key.
RouteObjectInterface::ROUTE_OBJECT contains '_route_object' instead.
Thank you for your review :)
Comment #13
DuaelFrRe-reading the code I've seen that I forgot to remove an use that I added during my first tests.
Comment #15
larowlanI think it would be more performant to change it from
<a title="really expensive to calculate title with lots of technical implications" href="some/url">Configure</a>
to
More valid for a11y and less expensive to calculate.
Comment #16
DuaelFrNew patch according to @larowlan suggestion.
Comment #17
DuaelFrWith @ instead of %.
Comment #18
larowlanLooking good - we can now remove the following properties/constructor arguments
routeMatch
menuLinkManager
routeProvider
titleResolver
major cleanup, less coupling++
:)
Comment #20
DuaelFrComment #22
larowlanAdding the tag to make sure a11y team agree with my assertions here
Comment #23
larowlanUpdated issue summary for a11y reviewers sake
Comment #24
chx CreditAttribution: chx commentedComment #26
DuaelFrFixed!
Comment #27
larowlanAssuming bit agrees
Thanks for your work duaelfr
Comment #28
mgiffordLooks good to me. Thanks @DuaelFr & @larowlan
Comment #32
alexpottDoing less is normally a good idea and inject 4 services for a link title feels excessive. And removing untested broken functionality makes sense too. Committed 19167f7 and pushed to 8.0.x. Thanks!