Problem/Motivation
Happens only in specific circumstances. In my case, I can only reproduce it when the site is using openeuropa/oe_multilingual module. In that case, when I enable modal_page module, the following error is displayed:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "modal_page.settings" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 211 of core/lib/Drupal/Core/Routing/RouteProvider.php).
Not sure what is the definite reason in this case, however, core's documentation for hook_install() is advising to use hook_modules_installed() when route information is required:
If the module provides a MODULE.routing.yml or alters routing information these changes will not be available when this hook is fired. If up-to-date router information is required, for example to use \Drupal\Core\Url, then (preferably) use hook_modules_installed() or rebuild the router in the hook_install() implementation.
Steps to reproduce
Tested on Drupal 10.5 and 11.2.
1. Enable openeuropa/oe_multilingual
2. Enable modal_page (the error is displayed both when using drush en modal_page or when using admin UI.
Proposed resolution
Use hook_modules_installed() to display the message.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3543767-7.patch | 1.03 KB | keszthelyi |
Issue fork modal_page-3543767
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
keszthelyi commentedComment #4
renatog commentedHey @keszthelyi , nice catch!
Thanks a lot for reporting and providing a solution for this
I'm reviewing the MR
Comment #5
renatog commentedAdded a suggestion in the MR
Comment #6
keszthelyi commentedComment #7
keszthelyi commentedUploading a patch file for the current MR state (our CI requires static patch files to be used).
Comment #8
renatog commentedComment #9
renatog commentedPR updated
.install.moduleP.S. This is just to follow the guidelines that asks that however it was working fine on .install, and honestly in the first time looking seems better to be there
Just a guess, but Maybe the reason why should be declared on is because you can implement this hook to "intercept" even when other modules has been installed, while
.installseems to be related only to own installationI'm not really sure about the reason, However it's definitely a valid fix and I'm going to merge that
Thank you so much @keszthelyi
Comment #11
renatog commentedReleased https://www.drupal.org/project/modal_page/releases/6.0.0-beta10
Thank you so much for your help with really nice contributions @keszthelyi
Comment #13
keszthelyi commented@renatog re move to .module: indeed, didn't notice, nice catch, thanks for fixing it!
Comment #14
renatog commentedMy pleasure