-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
51423: wp-admin/setup-config.php fixes fwrite handle mismatch #722
51423: wp-admin/setup-config.php fixes fwrite handle mismatch #722
Conversation
4bcfcaf
to
3848ed3
Compare
Force push to reset the file back to original state (except for the indentation). Why? To first show the problem exists in PHP 8, but not in the other PHP versions. Doing this step shows the problem in action for crafting the right fix without causing a breaking change. |
Manual Testing BEFORE the FixEnvironment:
To make it testable, needed to create an environment where
---------- 1 **** staff 3181 Mar 15 13:25 wp-config.php
clearstatcache( ABSPATH . 'wp-config.php' ); Test 1: with PHP 7.3.5Results: Works, but PHP Warning From the error.log
Test 2: with PHP 8.0Results: Does not work due to From the error.log
|
Manual Testing AFTER the FixSame environment and test conditions. Test 1: with PHP 7.3.5Results: Works with no breaking change.
Test 2: with PHP 8.0Results: Works.
|
47c5a4e
to
d1037b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Approved. Let's wait for a second opinion from the security team before submitting it for commit as we're touching the messaging to the end-user with potentially security sensitive information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed this with whitespace only changes suppressed.
These changes look good to me, a couple of comments/questions inline but nothing I consider a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, a couple more things.
Re: the string 'Unable to write to %s file.'
, no need to change if it's from another file. I must have done a silly when searching, probably had regex mode enabled or some such.
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely! I'll commit these changes today.
Reviewed with whitespace changes suppressed.
Committed in https://core.trac.wordpress.org/changeset/50775 |
Trac ticket: https://core.trac.wordpress.org/ticket/51423
fwrite
handle type mismatch which happens iffopen
fails, i.e. returnsfalse
Note:
The new conditional uses the absence of
false
instead of checking for a resource. Why? PHP has plans to changefopen
to returnobject
instead of currentresource
in a future version. This not falsey check though opposite ensures the code is future-proof when the new version is released.An inline comment (thanks @peterwilsoncc) is added to explain and provides a learning opportunity for those who read the code.
@props xknown, hellofromTonya, jrf, peterwilsoncc
TODO
chmod
failed error messagingThis Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.