I got this error on the screen after user save the registration form.

TypeError: _user_registrationpassword_mail_notify(): Return value must be of type array, true returned in _user_registrationpassword_mail_notify() (line 626 of modules/contrib/user_registrationpassword/user_registrationpassword.module).

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

freelylw created an issue. See original summary.

ritarshi_chakraborty’s picture

Working on it.

vinodhini.e’s picture

Hi, Tested the User Registration Password module with Drupal 11.2.3.

Encountered the same error during user registration:
TypeError: _user_registrationpassword_mail_notify(): Return value must be of type array, true returned.

The error occurred immediately after submitting the registration form.

Applied the Merge Request #19, and after that, user registration worked successfully without any issues. Thanks.

ritarshi_chakraborty’s picture

Status: Active » Needs review

The test failure doesn't seem to be related to the changes I made. It depends on how you are creating the test user using createUser().

freelylw’s picture

any progress please ? or any alternative module that I can use for this purpose ? Thank you.

ritarshi_chakraborty’s picture

Almost forgot about the issue—sorry for the delay! I’ve fixed all the pipeline errors now.

freelylw’s picture

Hi, should I just download the .module file to replace the one in my system ? Thank you.

ritarshi_chakraborty’s picture

Just change the return type to mixed on line 605.

joe huggans’s picture

Tested and fixes the issue for me, the annotation on the _user_registrationpassword_mail_notify function probably needs updating however to reflect that it can return a mixed value.

 * @return mixed
 *   Mixed result depending on mail send outcome. Typically a boolean
 *   indicating success when a notification is sent, or an empty array when
 *   no notification is configured.

I think we can mark this as RTBC once that is added?

jaypan’s picture

Is all the work on this patch necessary? I'm finding that changing this line:

user_registrationpassword.module(626):

    $output = $mail['result'] ?? [];

To this:

    $output = $mail['result'] ? $mail : [];

Solves the issue.

jaypan’s picture

I don't know how to create a separate fork or a different MR when one already exists, so here's a patch that someone can test.

rob c’s picture

@jaypan that patch looks really simple. Good job.

As a rule of thumb i always tried to stay in line with core.

There they do something similar:

  return empty($mail) ? NULL : $mail['result'];
coretex’s picture

It looks like this issue is the same as 3557575.

coretex’s picture

rob c’s picture

Yes it does look like a dupe. Up to the current maintainers, just here with some (hope good) advice. Try to not change the footprint / return: Drupal core states array|null, they just don't define it (it's in the comment tough).

If i had to choose a patch/MR it would be the most simple one @ #12 in this issue, with a minor mod like i pointed out in #13. (i know, the other issue is older) (if people implemented something really custom on top of this, they might need the returned data)

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

intrafusion changed the visibility of the branch 3557575-return-type-fix to hidden.

intrafusion’s picture

Taking on @jaypan & @rob-c comments, I have created a new MR which essentially mirrors core.

Without wanting to mark my own homework can someone quickly review this works as expected and I'll merge

coretex’s picture

Hi Colin, thanks for picking up this issue. The MR fixed the issue! The error is gone and I receive an email.

intrafusion’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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