Commit e025e2279e for wordpress.org
commit e025e2279e7c9f388745672769cef07348716e79
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date: Sat Oct 24 22:56:54 2026 +0000
Code Quality: Remove a redundant `is_wp_error()` check after uploading 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 https://github.com/WordPress/wordpress-develop/pull/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
diff --git a/wp-admin/update.php b/wp-admin/update.php
index c19e64e579..eb03091c33 100644
--- a/wp-admin/update.php
+++ b/wp-admin/update.php
@@ -179,7 +179,7 @@ if ( isset( $_GET['action'] ) ) {
$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'type', 'title', 'nonce', 'url', 'overwrite' ) ) );
$result = $upgrader->install( $file_upload->package, array( 'overwrite_package' => $overwrite ) );
- if ( $result || is_wp_error( $result ) ) {
+ if ( $result ) {
$file_upload->cleanup();
}
@@ -331,7 +331,7 @@ if ( isset( $_GET['action'] ) ) {
$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'type', 'title', 'nonce', 'url', 'overwrite' ) ) );
$result = $upgrader->install( $file_upload->package, array( 'overwrite_package' => $overwrite ) );
- if ( $result || is_wp_error( $result ) ) {
+ if ( $result ) {
$file_upload->cleanup();
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index b508f45fd7..4953e40a04 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta1-64693';
+$wp_version = '7.2-beta1-64694';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.