The problem
When a user with many comments cancels his account, this could lead to php memory issues.
What are the steps required to reproduce the bug?
Cancel the user account of a User with thousands of comments with a php memory limit of 256M.
What behavior were you expecting?
The account will be deleted and all comments are unpublished/updated as well.
What happened instead?
You get a php memory error and not all comments of the canceled user are deleted/updated.
Reason
The code were the comments are loaded and updated has no chunking or batching mechanic.
$comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setUnpublished();
$comment->save();
}
Comments
Comment #2
dtv_rb commentedComment #3
cilefen commentedComment #4
dtv_rb commentedHere is a first patch that implements a similar solution like the node module does.
Comment #9
catchComment #11
ameymudras commentedRe rolling the above patch to 9.5.x
Comment #14
nikhil_110 commentedRe-rolling patch to 9.5.x
Comment #15
nikhil_110 commentedComment #16
smustgrave commented#11 still applied to 9.5 cleanly so #14 reroll was unnecessary also no interdiff was included.
Comment #18
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #20
ameymudras commentedRemoving deprecated code from patch #10 and making it compatible with 10.1.x
Comment #21
ameymudras commentedComment #26
samitk commentedHello,
Batch process for comment_user_cancel has been added.
Thanks
Samit K.
Comment #27
smustgrave commentedSeems to the patch from #21 was anything different done?
Comment #28
samitk commentedHi @smustgrave ,
It has a small difference that i introduced the
BatchBuilderclass to create batch, also upgrade the code as per Drupal 11 standards like by replacingmodule_load_includefunction.Thanks
Samit K.
Comment #29
smustgrave commentedTags are still relevant