Repository navigation
Conversation
…g a plugin or theme. After a plugin or theme is installed from an uploaded ZIP file, the upload is cleaned up when `$result || is_wp_error( $result )`. A `WP_Error` is an object and so always truthy, which means the first operand already covers it and the `is_wp_error()` call can never return `true`. The condition is therefore reduced to `$result`, which behaves identically: the upload is still cleaned up after a failed installation, and only kept when `false` is returned because filesystem credentials are requested, so it is still there once they are entered. This resolves the `function.impossibleType` errors reported by PHPStan, so that baseline is removed. See #65817.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟢 Approval recommended
Both conditions preserve existing behavior, and the baseline removal matches the two resolved warnings.
No open issues 🎉
What changed in this PR
Simplifies upload cleanup conditions for plugin and theme installations without changing behavior, and removes the resolved PHPStan baseline.
Changes:
- Removes redundant
is_wp_error()checks from both upload cleanup conditions. - Deletes the baseline covering the two resolved warnings and removes its configuration entry.
| File | Description |
|---|---|
tests/phpstan/baselines/function.impossibleType.neon |
Deletes the baseline for the two resolved warnings. |
src/wp-admin/update.php |
Simplifies plugin and theme upload cleanup conditions. |
phpstan.neon.dist |
Removes the deleted baseline’s include entry. |
Review effort: Balanced
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks! The changes look good to me, and CI passes.
…g a plugin or theme. After a plugin or theme is installed from an uploaded ZIP file in `wp-admin/update.php`, the upload is cleaned up when `$result || is_wp_error( $result )`. A `WP_Error` is an object and therefore always truthy, so the first operand already covers it and the `is_wp_error()` call can never return `true`. PHPStan reports this as `function.impossibleType`. The condition is reduced to `if ( $result )`, which behaves identically: a failed installation still cleans up the upload, and only `false`, which `WP_Upgrader::run()` returns when filesystem credentials are requested, keeps the upload so it is still there once the credentials are entered. This empties the `function.impossibleType` baseline, so the file and its entry in `phpstan.neon.dist` are removed. Developed in #14778. Props Soean. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@64694 602fd350-edb4-49c9-b593-d223f7449a82
…g a plugin or theme. After a plugin or theme is installed from an uploaded ZIP file in `wp-admin/update.php`, the upload is cleaned up when `$result || is_wp_error( $result )`. A `WP_Error` is an object and therefore always truthy, so the first operand already covers it and the `is_wp_error()` call can never return `true`. PHPStan reports this as `function.impossibleType`. The condition is reduced to `if ( $result )`, which behaves identically: a failed installation still cleans up the upload, and only `false`, which `WP_Upgrader::run()` returns when filesystem credentials are requested, keeps the upload so it is still there once the credentials are entered. This empties the `function.impossibleType` baseline, so the file and its entry in `phpstan.neon.dist` are removed. Developed in WordPress/wordpress-develop#14778. Props Soean. See #65817. Built from https://develop.svn.wordpress.org/trunk@64694 git-svn-id: http://core.svn.wordpress.org/trunk@63844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
After a plugin or theme is installed from an uploaded ZIP file in
wp-admin/update.php, the upload is cleaned up when$result || is_wp_error( $result ). AWP_Erroris an object and therefore always truthy, so the first operand already covers it and theis_wp_error()call can never returntrue. PHPStan reports this asfunction.impossibleType.The condition is reduced to
if ( $result ), which behaves identically: a failed installation still cleans up the upload, and onlyfalse, whichWP_Upgrader::run()returns when filesystem credentials are requested, keeps the upload so it is still there once the credentials are entered.This empties the
function.impossibleTypebaseline, so the file and its entry inphpstan.neon.distare removed.Trac ticket: https://core.trac.wordpress.org/ticket/65817
This 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.