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

Command icon 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

wells created an issue. See original summary.

wells’s picture

Status: Active » Needs review

I have opened MR !2 with my initial approach to handling this process in a batch.

gwvoigt made their first commit to this issue’s fork.

gwvoigt’s picture

Added a commit to make it compatible to D10 since QueryInterface::accessCheck is now required.

ivnish’s picture

Status: Needs review » Needs work

Needs rebase

deaom made their first commit to this issue’s fork.

deaom’s picture

Version: 8.x-4.x-dev » 5.x-dev

Rebased 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.

deaom’s picture

Status: Needs work » Needs review

Added a Kernel test for the batch delete, probably ready for review.