Skip to content

Commit

Permalink
Merge pull request #19906 from MikeyMJCO/patch-8
Browse files Browse the repository at this point in the history
Rebuild the Drupal route cache.
  • Loading branch information
eileenmcnaughton authored Mar 26, 2021
2 parents cc89c07 + a11c108 commit 93f40fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CRM/Core/Invoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionRes
CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')
) {
CRM_Core_DAO::triggerRebuild();
$config->userSystem->invalidateRouteCache();
}
CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
Expand Down
6 changes: 6 additions & 0 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,4 +1012,10 @@ public function getCMSPermissionsUrlParams() {
return [];
}

/**
* Invalidates the cache of dynamic routes and forces a rebuild.
*/
public function invalidateRouteCache() {
}

}
10 changes: 10 additions & 0 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,4 +858,14 @@ public function getUserObject($userID) {
return \Drupal::entityTypeManager()->getStorage('user')->load($userID);
}

/**
* Helper function to rebuild the Drupal 8 or 9 dynamic routing cache.
* We need to do this after enabling extensions that add routes and it's worth doing when we reset Civi paths.
*/
public function invalidateRouteCache() {
if (class_exists('\Drupal') && \Drupal::hasContainer()) {
\Drupal::service('router.builder')->rebuild();
}
}

}

0 comments on commit 93f40fc

Please sign in to comment.