Php error: undefined variable, if new user registration fails

Using a default install on Ubuntu 18.04, I’m seeing errors like the below if user registration fails. The simplest way to reproduce is to try to register two accounts with the same email address.

[error] 11029#11029: *165 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: user in /srv/www/<redacted>/app/sprinkles/account/src/Controller/AccountController.php on line 926" while reading response header from upstream, client: <redacted>, server: <redacted>, request: "POST /account/register HTTP/1.1"

Looking at the PHP code (I’m a C programmer, not a PHP expert) should the block that uses $user be inside the try block just above?

Thanks for the report. I’ll raise this in the Dev chat so it doesn’t get missed.

Just to be sure @jch, which version of UserFrosting are you using?

I replicated with a different error message:

    "message": "Call to a member function toArray() on null",
    "exception": [
            "type": "Error",
            "code": 0,
            "message": "Call to a member function toArray() on null",
            "file": "\/home\/vagrant\/UserFrosting\/app\/sprinkles\/account\/src\/Controller\/AccountController.php",
            "line": 926

Note this doesn’t happens when creating a user manually through the admin panel. I’ll open a new issue.

I’m using version 4.2.0 on Ubuntu 18.04.
I’m not using the admin panel. Users register using the register page.

Good. See here :

May have a fix for it. You can try branch hotfix-issue#953.