Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x]: Warning from getUserTemporaryUploadFolder due to null user #11751

Closed
chrismlusk opened this issue Aug 8, 2022 · 5 comments
Closed

[3.x]: Warning from getUserTemporaryUploadFolder due to null user #11751

chrismlusk opened this issue Aug 8, 2022 · 5 comments

Comments

@chrismlusk
Copy link

What happened?

Description

Our error monitoring logs are showing thousands of the following ErrorException message:

Warning: Attempt to read property "id" on null

Per the stack trace, this is happening when the getUserTemporaryUploadFolder method is called.

    public function getUserTemporaryUploadFolder(User $user = null)
    {
        if ($user === null) {
            // Default to the logged-in user, if there is one
            $user = Craft::$app->getUser()->getIdentity();
        }

        if (isset($this->_userTempFolders[$user->id])) { # <-- issue happens here
            return $this->_userTempFolders[$user->id];
        }

The getIdentity method can return null, hence the warning about reading the id property.

Although I marked this as a Craft 3 bug, it looks like it might affect 4.x as well.

Craft CMS version

3.7.50

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@brandonkelly
Copy link
Member

Thanks for reporting that! Just fixed for the next Craft 3 and 4 releases.

@brandonkelly
Copy link
Member

Craft 3.7.51 and 4.2.1 are out with the fix.

@chrismlusk
Copy link
Author

Hi Brandon, it looks like this issue is still happening when there is no logged-in user. There are two additional attempts to access $user->id later on in the method:

brandonkelly added a commit that referenced this issue Aug 22, 2022
@brandonkelly
Copy link
Member

Doh, thanks. Fixed now.

@brandonkelly
Copy link
Member

Craft 3.7.52 and 4.2.2 are out now with those fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants