Php error: undefined variable, if new user registration fails


#1

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?


#2

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


#3

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.


#4

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


#5

Good. See here :


#6

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