Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tr_rulez
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
tr_rulez
Commits
cde37d9a
Commit
cde37d9a
authored
3 years ago
by
Tim Rohaly
Committed by
Tim Rohaly
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3257884
by TR: Rename events - invalidate cache tags
parent
b9233df6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tr_rulez.install
+32
-2
32 additions, 2 deletions
tr_rulez.install
with
32 additions
and
2 deletions
tr_rulez.install
+
32
−
2
View file @
cde37d9a
...
...
@@ -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
));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment