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.
Issue fork private_message-3356586
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
Comment #4
ranjit1032002Created MR!68 for the issue mentioned, please review.
Thank you.
Comment #5
wstocker commentedMR!68 Looks good to me. Tested with Drupal 9 PHP 8.
Comment #6
wstocker commentedChanging status to "Reviewed & testing by the community."
Comment #9
artem_sylchukThanks for catching that, merged!