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

Fix error when posix_getpwuid returns false #10299

Merged
merged 1 commit into from
May 5, 2022

Conversation

edwilde
Copy link
Contributor

@edwilde edwilde commented May 3, 2022

The posix_getpwuid function can return false if it fails (see docs).

If this happens, it results in a notice output in the CMS/front-end and broken functionality.
Notice: Trying to access array offset on value of type bool in ***/vendor/silverstripe/framework/src/Core/TempFolder.php on line 42

Screen Shot 2022-05-04 at 8 24 30 AM

Since there is a cascade in the getTempFolderUsername() function, I would assume it is safe to have $user set to false if it fails and to continue to look for another method to populate it successfully.


Observed in PHP 7.4.28 + PHP 7.4.29, macOS 12.3.1, M1 pro

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, I didn't know the null coalescing operator could be used in that situation, but I've tested it and it does work.

@GuySartorelli GuySartorelli changed the base branch from 4 to 4.11 May 5, 2022 07:12
@GuySartorelli
Copy link
Member

@edwilde I've retargetted this at the new 4.11 branch. Normally this would go in a patch release but in this case since 4.11 is in beta it'll be in the 4.11.0 minor release.

@GuySartorelli GuySartorelli merged commit baaa323 into silverstripe:4.11 May 5, 2022
@edwilde
Copy link
Contributor Author

edwilde commented May 5, 2022

Sweet, thanks @GuySartorelli 👍

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

Successfully merging this pull request may close these issues.

3 participants