Skip to content
Snippets Groups Projects
Commit cde37d9a authored by Tim Rohaly's avatar Tim Rohaly Committed by Tim Rohaly
Browse files

Issue #3257884 by TR: Rename events - invalidate cache tags

parent b9233df6
Branches
Tags
No related merge requests found
......@@ -5,6 +5,8 @@
* Install, update, and uninstall functions for the tr_rulez module.
*/
use Drupal\Core\Cache\Cache;
/**
* Updates the name of the Rules Events provided by tr_rulez.
*
......@@ -27,8 +29,9 @@
*/
function tr_rulez_update_8101() {
// The Events to rename are stored in this array as:
// 'old_event_name' => 'new_event_name'
// The Events to rename are stored in this array.
// The keys are the old event names, and the corresponding values are
// the new event_names.
$renamed_events = [
'tr_rulez_user_was_blocked' => 'tr_rulez.user_was_blocked',
'tr_rulez_user_was_unblocked' => 'tr_rulez.user_was_unblocked',
......@@ -87,3 +90,30 @@ function tr_rulez_update_8101() {
}
}
/**
* Invalidates the cache for reaction rules modified in tr_rulez_update_8101().
*
* This hook invalidates cache tags for all reaction rules that use events
* renamed by tr_rulez_update_8101(). This is necessary to eliminate all
* reference to the old events.
*
* @see https://www.drupal.org/project/tr_rulez/issues/3257884
*/
function tr_rulez_update_8102() {
// The Events to rename are stored in this array.
// The keys are the old event names, and the corresponding values are
// the new event_names.
// This array is identical to the array used in tr_rulez_update_8101().
$renamed_events = [
'tr_rulez_user_was_blocked' => 'tr_rulez.user_was_blocked',
'tr_rulez_user_was_unblocked' => 'tr_rulez.user_was_unblocked',
'tr_rulez_entity_bundle_create' => 'tr_rulez.entity_bundle_create',
'tr_rulez_entity_bundle_delete' => 'tr_rulez.entity_bundle_delete',
];
// Reaction rules are cached in the RulesComponentRepository using the
// name(s) of their registered event(s) as cache tags. We need to invalidate
// the cache for those rules that use the old event names.
Cache::invalidateTags(array_keys($renamed_events));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment