Problem/Motivation

`strpos()` has the arguments swapped, in the method `private_message_preprocess_container()`.

Wrong: `strpos('edit-members-wrapper', $vars['element']['#id'])`
Correct: `strpos($vars['element']['#id'], 'edit-members-wrapper')`

I recall, the first argument is the haystack and the second is the needle. See here.

This is usually unnoticed because the needle is exactly the same has the haystack. But in my case I'm using a modal and the id comes concatenated with a token. In this case, `strpos()` returns false when it should return true.

Steps to reproduce

Just looking at the code, you can see that the arguments are swapped. It doesn't make sense to check if `$vars['element']['#id']` is a substring `'edit-members-wrapper'`.

If you really want to see this break, you can make the link to Create Private Message (route `private_message.private_message_page`) to open in a modal. This requires some simple steps that I won't put here.

Proposed resolution

Use the function `str_starts_with()` with the correct arguments.

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

Assigned: dxvargas » Unassigned
Status: Active » Needs review

I've created a MR.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Correct

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Thank you

Status: Fixed » Closed (fixed)

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