Problem/Motivation

Private messaging fields used on the user create admin form. When this form is saved it triggers an error because $user_data is NULL.

There is this if statement:

// Try to fetch user's settings if it is not a registration form.
    if ($user->id()) {
   }

However, outside of that there are two method calls to get methods on $user_setting when $user->id is NULL so it doesn't go into the if statement to set $user_data but still goes on to call $user_data get methods.

Steps to reproduce

Save user registration form:

Call to a member function get() on null in private_message_form_user_form_alter() (line 324 of modules/contrib/private_message/private_message.module).

Call to a member function get() on null in private_message_form_user_form_alter() (line 356 of modules/contrib/private_message/private_message.module).

Proposed resolution

Check if $user_data is set before trying to access get method.

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

wstocker created an issue. See original summary.

Ranjit1032002 made their first commit to this issue’s fork.

ranjit1032002’s picture

Status: Active » Needs review

Created MR!68 for the issue mentioned, please review.
Thank you.

wstocker’s picture

MR!68 Looks good to me. Tested with Drupal 9 PHP 8.

wstocker’s picture

Status: Needs review » Reviewed & tested by the community

Changing status to "Reviewed & testing by the community."

artem_sylchuk made their first commit to this issue’s fork.

artem_sylchuk’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for catching that, merged!

Status: Fixed » Closed (fixed)

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