Problem/Motivation

When deleting the first message of a thread, the second message will not be shown in the thread.

This problem comes after this commit:
https://git.drupalcode.org/project/private_message/-/commit/4d3384197ab0...

Before, the array returned by getMessages() was always indexed starting on zero and incremented by one. After this commit, the array of messages can be indexed in different ways and when the first message is deleted it will start in 1.

This has an impact in filterUserDeletedMessages() because it relies on the old indexes to slice the array.

Even inside the method getMessages(), it seems that there is a related problem because it is also supposing that the index is always zero for the banned filter.

Steps to reproduce

# Create two messages in a thread;
# Delete the first message;
# Check that both messages disappear from the thread.

Proposed resolution

The array of messages inside getMessages() should be as before, with incremental indexes starting on zero.

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

dxvargas created an issue. See original summary.

dxvargas’s picture

Status: Active » Needs work
claudiu.cristea’s picture

Do we need to fix also 3.0.x as #3488508: Thread deletion might leave leftover messages. was merged also there?

dxvargas’s picture

Yes @claudiucristea, I confirm we need a backport for 3.0.x.
Teh code is pretty much the same, in this regards.

claudiu.cristea’s picture

Version: 4.x-dev » 3.0.x-dev
Issue tags: -Needs backport to 3.0.x

Backporting...

  • claudiu.cristea committed 2b0b5f59 on 3.0.x
    Issue #3501286 by claudiu.cristea, dxvargas: Error caused by indexes of...
claudiu.cristea’s picture

Status: Needs work » Fixed

Thank you for finding and fixing the issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.