-
Notifications
You must be signed in to change notification settings - Fork 107
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 passing error messages to wp_die() when plugin activation fails #1126
Fix passing error messages to wp_die() when plugin activation fails #1126
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
@westonruter LGTM, though I'd prefer your alternative suggestion.
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.
Nice catch, @westonruter. We should prioritize #775 as soon as possible.
When working on preparing for the 3.0.0 release in #1125 I ran
npm run since -- -r 3.0.0
which touchedincludes/admin/load.php
. When I went to commit,lint-staged
failed the pre-commit check with the following error:In looking at the code in question, I see there was indeed an error as
$result->get_error_messages()
returns an array of strings, and this can't be passed toesc_html()
without first imploding to a string. It's confusing from the codebase because further up there is this:performance/includes/admin/load.php
Lines 269 to 275 in 2b7b878
Specifically note the last line
wp_die( esc_html( $skin->get_error_messages() ) )
. This is actually valid becauseWP_Ajax_Upgrader_Skin::get_error_messages()
returns astring
while the method of the same name onWP_Error
returnsstring[]
.I discovered this issue because I have a local
phpstan.neon
which has a stricter level (at level 6) thanphpstan.neon.dist
(at level 0):The above issue was identified with level 5:
Nevertheless, PhpStorm's static analysis also flagged this as an error:
Compare with PHPStan's error being surfaced in PhpStorm (which was returned above via
lint-staged
):Sure enough, when I simulate a failure in
activate_plugin()
, I did get a PHP warning:We really should prioritize increasing the PHPStan level (#775) so we can catch these issues earlier than a couple days before the release.