Thread deletion might leave leftover messages.

Created on 20 November 2024, about 2 months ago

Problem/Motivation

When deleting a thread, I would expect all relevant messages to be removed as well.

Currently, the \Drupal\private_message\Entity\PrivateMessageThread::delete is supposed to be loading all messages and delete them, but the underlying \Drupal\private_message\Entity\PrivateMessageThread::getMessages method, is having an edge case where it might skip a few messages.

Steps to reproduce

I will provide a test and a solution, but the main idea is:
* Create 2 users, user A, and user B.
* Create a ban from user A to user B.
* Login as user A.
* Delete the thread.

Because the user A has banned user B, they are not able to view the messages from user B because \Drupal\private_message\Entity\PrivateMessageThread::getMessages is filtering them out using the current user as a fixed source of identification.
However, the delete method also calls for this method and if there is an active session of user A, the messages found to be deleted are filtering out the banned messages.

Proposed resolution

Add an optional parameter to the ::getMessages() method to allow the delete method to call it and include banned messages.

This will retain the BC as well.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece idimopoulos

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024