Problem/Motivation
When a registrant is added / changed / deleted, the cache of the parent event instance should be invalidated so that the availability count is updated. If the event registration type is "Series" then the event series should be invalidated as well.
Currently this is handled in form submit handlers, but whenever a registrant is updated programmatically the caches are not invalidated. This means that whenever a change is happening outside of a form the counts are outdated. This affects migrations, Drush commands, REST API calls etc.
Steps to reproduce
- Create a registrant for an event instance.
- Take note of the entity ID of the created registrant.
- View the event instance page so that it will become cached. Take note of the available places.
- Delete the registrant without using our form (e.g.
drush entity:delete registrant {id})
Expected result: the availability count for the event instance should increase by 1.
Actual result: the caches are not invalidated and the availability count for the event instance remains the same.
Proposed resolution
Use EntityInterface::getCacheTagsToInvalidate() rather than manually invalidating the cache tags on form submit.
Issue fork recurring_events-3454012
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
pfrenssenComment #6
owenbush commentedThis looks good and cleaned up a lot of unnecessary code, thank you