Skip to content

Commit 1cdf865

Browse files
committed
Code Quality: Stop passing a WP_Error to the skin's before().
The bulk compatibility checks in `Plugin_Upgrader::bulk_upgrade()` and `Theme_Upgrader::bulk_upgrade()` handed the `WP_Error` they had just built to `$this->skin->before()`, which takes no parameter. The `$this->skin->error( $result )` call on the next line is what reports the failure, and the `$this->skin->after()` call below it already passes nothing. The argument was inert only because of which skin those paths reach. Both `Bulk_Plugin_Upgrader_Skin::before()` and `Bulk_Theme_Upgrader_Skin::before()` ignore the `$title` they are given and call the parent with the plugin or theme name instead, so the object was discarded before anything could read it. A skin without that override, such as a plain `Bulk_Upgrader_Skin`, instead places it in the `%1$s` of the `Updating Plugin %1$s (%2$d/%3$d)` header, where PHP 8 throws `Object of class WP_Error could not be converted to string` and takes down the update screen. Removing the argument closes a latent fatal rather than only tidying an unused value. Nothing reads the parameter today: every `before()` implementation in core either declares none at all or documents a `string $title`, and a survey of the plugin and theme directories turned up no consumer: only copies of this same loop passing the same dead argument. This empties `tests/phpstan/baselines/arguments.count.neon`, so as that file's header directs it is deleted along with its `includes` entry in `phpstan.neon.dist`. Developed in WordPress#13571. Follow-up to r56525, r57252, r63020. Props soean. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@63788 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 825b49c commit 1cdf865

4 files changed

Lines changed: 4 additions & 35 deletions

File tree

‎phpstan.neon.dist‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ includes:
2424
# phpstan:baselines start
2525
- tests/phpstan/baselines/argument.type.neon
2626
- tests/phpstan/baselines/argument.unresolvableType.neon
27-
- tests/phpstan/baselines/arguments.count.neon
2827
- tests/phpstan/baselines/arrayValues.list.neon
2928
- tests/phpstan/baselines/assign.propertyType.neon
3029
- tests/phpstan/baselines/binaryOp.invalid.neon

‎src/wp-admin/includes/class-plugin-upgrader.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function bulk_upgrade( $plugins, $args = array() ) {
356356
)
357357
);
358358

359-
$this->skin->before( $result );
359+
$this->skin->before();
360360
$this->skin->error( $result );
361361
$this->skin->after();
362362
} elseif ( isset( $upgrade_data->requires_php ) && ! is_php_version_compatible( $upgrade_data->requires_php ) ) {
@@ -370,7 +370,7 @@ public function bulk_upgrade( $plugins, $args = array() ) {
370370
)
371371
);
372372

373-
$this->skin->before( $result );
373+
$this->skin->before();
374374
$this->skin->error( $result );
375375
$this->skin->after();
376376
} else {

‎src/wp-admin/includes/class-theme-upgrader.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public function bulk_upgrade( $themes, $args = array() ) {
454454
)
455455
);
456456

457-
$this->skin->before( $result );
457+
$this->skin->before();
458458
$this->skin->error( $result );
459459
$this->skin->after();
460460
} elseif ( isset( $upgrade_data['requires_php'] ) && ! is_php_version_compatible( $upgrade_data['requires_php'] ) ) {
@@ -468,7 +468,7 @@ public function bulk_upgrade( $themes, $args = array() ) {
468468
)
469469
);
470470

471-
$this->skin->before( $result );
471+
$this->skin->before();
472472
$this->skin->error( $result );
473473
$this->skin->after();
474474
} else {

‎tests/phpstan/baselines/arguments.count.neon‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)