comment_user_cancel() doesn't implement a batch

Created on 18 October 2018, about 6 years ago
Updated 10 September 2024, 2 months 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 work

Version

11.0 ๐Ÿ”ฅ

Component
Commentย  โ†’

Last updated 1 day 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.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

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.71.5 2024