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
The Help page for token module (/admin/help/token) only shows a single character - '1'. This should show a token browser.
Comment | File | Size | Author |
---|---|---|---|
#2 | help_page_does_not-2639324-2.patch | 785 bytes | hussainweb |
|
Comments
Comment #2
hussainwebI should clarify that this might not always happen. The problem is this code:
The
toString()
method returns the full path including any directory prefix (which was the case in my test instance). We can usegetInternalPath()
instead which returns only the part of the route we care about.However, that said, I am not sure if this part is really required anymore. This might have been required in Drupal 7 where the
$path
passed by the help module would be a made-up path; however, the route here is not. I tested this manually by applying breakpoints and trying various help pages. The patch removes the block altogether.Comment #3
BerdirThe reason it's there is to avoid wasting a lot of time on admin/modules for building that token tree but then not actually using it, since it is not displayed.
I think that still happens, but it's possible that there is a better way to check that now, can you check what kind of routes are passed in on that page exactly? And if hook_help() is really still called there? ( it used to be to decide if the help link for a module should be shown or not)
Comment #4
hussainweb@Berdir: Not as per my tests. The hook is still called but the route_name is different because of which it does not even enter the first if check.
I repeated the tests to be sure, though. I cleared the cache before loading the help pages.
admin/help
, $route_name is 'help.main'. It never enters the if block.admin/help/field
, $route_name is 'help.page'. Never enters the if block.admin/help/rdf
, $route_name is 'help.page'. Never enters the if block.admin/help/token
, this hook is fired twice. First with $route_name = 'help.page.token' which enters the first if check but returns without rendering the token browser (which is the bug). Second invocation of hook has $route_name = 'help.page', and never enters the if block.This means that the hook is invoked for all hook pages but the route name we are checking is only set for token's own help page. This also means that we can safely remove the entire inner if block.
Comment #6
BerdirYeah, other help pages are definitely fine, not worried about that. But admin/modules would be different. But that was fixed in core, the relevant part is:
This does solve the exact problem that we have. Yay D8 :) So yes, removing it s fine. Committed.