-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rebuild the Drupal route cache. #19906
Conversation
(Standard links)
|
Alternative approach for #19888 |
Test sites: D8: https://d8pr19906.bkonaz.mjco.uk/ |
I think what @seamuslee001 meant on the other PR by CRM_Utils_System_x classes is that instead of hardcoding Drupal8, here in Invoke you would call |
That makes sense. |
Refactored with @demeritcowboy 's suggested route and squashed. |
I tested this in drupal 9 with cdntaxreceipts but I still needed to clear drupal cache after in order to avoid the "page not found". Hmmmm. |
If you switch it out to do |
This is linked to [issue 158](https://lab.civicrm.org/dev/drupal/-/issues/158) and [issue 37](https://lab.civicrm.org/dev/drupal/-/issues/37). It takes an alternative approach, adding a Util hook function to rebuild the route cache which we can then invoke from multiple places. Trigger `rebuildDrupalRouteCache()` when running `triggerRebuild()` Fix checkstyle issues Change function from `protected` to `public` Update Drupal8.php Add base for `invalidateRouteCache()` Add invalidateRouteCache function Add call to userFramework->invalidateRouteCache Update Base.php Correct `userFramework` to `userSystem` Remove stray whitespace. Move invalidateRouteCache call to the same place as resetNavigation. Update Invoke.php Switch to the `router.builder' option as invalidating the cache doesn't cut it.
Okay this works now, it turns out we do need to do a |
Ok neat. I guess we're then back to where is the best place. So this would trigger on any extension action even disable but maybe that's ok/desired. |
Yeah, I'm thinking that having extension routes in the cache post-disable is undesirable so it's cleaner to run this on any extension enable/disable/install/uninstall. |
|
I went with checking for |
Thanks for the review @demeritcowboy - I think the r-maint is OK since it's just a little bit of code that seems pretty readable |
@MikeyMJCO this is 'linked to issues' - are they closable now or just linked |
Closeable along with PR #19888 |
Issues and other PR closed :-) |
thanks |
@MikeyMJCO - although I see I said above the code is pretty readable I'm reading it now & I'm confused :-) Specifically I don't understand why it's nested in the if trigger part here - because it seems the line is about rebuilding paths which is 'all the rest of the function' rather than re-instating logging If it IS correct for it to be in that loop maybe you could add a PR to explain why it should only be done when rebuilding mysql triggers |
It's a computationally very expensive operation - like rebuilding triggers. It's not something that should be called as often as we flush caches - the performance cost would be very high. When we do things like disable/enable or upgrade extensions we're already setting civicrm-core/CRM/Extension/Manager.php Line 228 in c706f46
|
Described in comments in #20414 |
Overview
This is linked to issue 158 and issue 37.
It takes an alternative approach to #19888, adding a Utils/System function to rebuild the routes which we can then invoke from multiple places if required with an invocation added to the rebuildMenuandCaches function in invoke.php.
Before
Enabling a CiviCRM extension that adds a route on Drupal 8 or 9 results in a 404 until the routes are rebuilt in Drupal.
After
Enabling/disabling an extension rebuilds Drupal's routes and routes added in CiviCRM work as expected..
Technical Details
There might be a more performant option for this but I can't find anything...