For class names that appear in routing.yml files, core sometimes prefixes these class names with "\" and sometimes doesn't.
For example, in system.routing.yml, observe that the first _controller uses "\Drupal" while the second in just uses "Drupal"
system.cron:
path: '/cron/{key}'
defaults:
_controller: '\Drupal\system\CronController::run'
options:
no_cache: TRUE
requirements:
_access_system_cron: 'TRUE'
system.admin_compact_page:
path: '/admin/compact/{mode}'
defaults:
_controller: 'Drupal\system\Controller\SystemController::compactPage'
mode: 'off'
requirements:
_permission: 'access administration pages'
I found this to be a problem with class names appearing in _controller, _form, and _title_callback
The attached patch makes all class names start with "\Drupal".
Comments
Comment #2
cindytwilliams commentedPatch applies cleanly, and updates all instances of "Drupal" in system.routing.yml with "\Drupal". Navigations and links continue to work as expected. Marking RTBC.
Comment #3
wim leersHAH! This has bothered me so many times :D 🤓
Comment #4
tr commentedAll I can say is "Attention to detail does not necessarily make code good. But INattention to detail frequently makes code bad."
Thanks for the "Trivial patch of the month" tag. I will treasure it forever. Although you know the issue is four months old ...
Comment #5
catchAre there other core routing declarations with the same problem? If so we should update them all in this issue.
Comment #6
tr commented@catch: This covers everything in all core *.routing.yml files - any key that might take a class name as a value in these files has been checked.
Do you mean other non-routing places, such as core.services.yml? (Yes, this and other services.yml files also have a similar problem)
Or are you talking about other types of non-routing yml files, like yml used for plugin discovery (*.links.action.yml, *.links.menu.yml, etc.) and yml migration templates? (Yes, these all also show a similar problem)
I am concerned that if we expand this to service declarations it will become too large and affect too many things. Especially since core.services.yml seems to have chosen a standard of NOT using fully qualified the class names, which is opposite of what we normally do in *.routing.yml etc.
Comment #7
wim leers#4: well said!
@catch specifically asked about other
*.routing.ymlfiles, not*.services.yml. There are indeed many more. For example ineditor.routing.yml,quickedit.routing.yml, and so on. We can quite easily fix all of those here too.I should've checked that — I was a bit too excited to see this finally get fixed :D
Comment #8
tr commentedThe source of my confusion is that I thought the original patch covered all
*.routing.ymlfiles, but now I see it did not, even though that was my intention.Here is a new patch which this time really does fix all the
*.routing.ymlfiles.Comment #9
wim leersHeh :)
Thanks for doing this! 👍
Comment #10
catchCommitted 3d27d76 and pushed to 8.8.x. Thanks!
Comment #12
catch