comment_user_cancel() doesn't implement a batch

Created on 18 October 2018, over 5 years ago
Updated 13 February 2023, over 1 year ago

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();
      }
🐛 Bug report
Status

Needs review

Version

10.1

Component
Comment 

Last updated 2 days ago

Created by

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024