Problem/Motivation
When attempting to delete a flag with thousands of flaggings, the regular core entity delete behavior will run out of memory attempting to delete all the flaggings.
Steps to reproduce
Create a flag and add a high number of flaggings (e.g. 50k).
Attempt to delete the flag from /admin/structure/flags.
The operation will fail when PHP runs out of memory while attempting to delete all related flagging entities.
Proposed resolution
Delete a flag's flagging entities in a batch operation.
Remaining tasks
Review and improve initial approach. I have attempted to use as much as the extending entity delete functionality as possible, but it does lead to some oddities (e.g. the entity deleted message and log is added before the batch operation completes).
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork flag-3192628
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
wellsI have opened MR !2 with my initial approach to handling this process in a batch.
Comment #5
gwvoigtAdded a commit to make it compatible to D10 since QueryInterface::accessCheck is now required.
Comment #6
ivnishNeeds rebase
Comment #9
deaom commentedRebased 8.x branch and then cherry picked the commits onto 5.x branch. Leaving to needs work as I assume some additional test is needed.
Comment #10
deaom commentedAdded a Kernel test for the batch delete, probably ready for review.