Skip to content

Commit b917c41

Browse files
Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/class-plugin-upgrader.php.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$return` variable in `Plugin_Upgrader` class methods to `$response` and updates the documentation accordingly. Follow-up to [47409], [52946], [52996]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. git-svn-id: https://develop.svn.wordpress.org/trunk@52997 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6244d51 commit b917c41

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -505,19 +505,19 @@ public function plugin_info() {
505505
* @since 2.8.0
506506
* @since 4.1.0 Added a return value.
507507
*
508-
* @param bool|WP_Error $return Upgrade offer return.
509-
* @param array $plugin Plugin package arguments.
510-
* @return bool|WP_Error The passed in $return param or WP_Error.
508+
* @param bool|WP_Error $response The installation response before the installation has started.
509+
* @param array $plugin Plugin package arguments.
510+
* @return bool|WP_Error The original `$response` parameter or WP_Error.
511511
*/
512-
public function deactivate_plugin_before_upgrade( $return, $plugin ) {
512+
public function deactivate_plugin_before_upgrade( $response, $plugin ) {
513513

514-
if ( is_wp_error( $return ) ) { // Bypass.
515-
return $return;
514+
if ( is_wp_error( $response ) ) { // Bypass.
515+
return $response;
516516
}
517517

518518
// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it.
519519
if ( wp_doing_cron() ) {
520-
return $return;
520+
return $response;
521521
}
522522

523523
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
@@ -530,7 +530,7 @@ public function deactivate_plugin_before_upgrade( $return, $plugin ) {
530530
deactivate_plugins( $plugin, true );
531531
}
532532

533-
return $return;
533+
return $response;
534534
}
535535

536536
/**
@@ -540,33 +540,33 @@ public function deactivate_plugin_before_upgrade( $return, $plugin ) {
540540
*
541541
* @since 5.4.0
542542
*
543-
* @param bool|WP_Error $return Upgrade offer return.
544-
* @param array $plugin Plugin package arguments.
545-
* @return bool|WP_Error The passed in $return param or WP_Error.
543+
* @param bool|WP_Error $response The installation response before the installation has started.
544+
* @param array $plugin Plugin package arguments.
545+
* @return bool|WP_Error The original `$response` parameter or WP_Error.
546546
*/
547-
public function active_before( $return, $plugin ) {
548-
if ( is_wp_error( $return ) ) {
549-
return $return;
547+
public function active_before( $response, $plugin ) {
548+
if ( is_wp_error( $response ) ) {
549+
return $response;
550550
}
551551

552552
// Only enable maintenance mode when in cron (background update).
553553
if ( ! wp_doing_cron() ) {
554-
return $return;
554+
return $response;
555555
}
556556

557557
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
558558

559559
// Only run if plugin is active.
560560
if ( ! is_plugin_active( $plugin ) ) {
561-
return $return;
561+
return $response;
562562
}
563563

564564
// Change to maintenance mode. Bulk edit handles this separately.
565565
if ( ! $this->bulk ) {
566566
$this->maintenance_mode( true );
567567
}
568568

569-
return $return;
569+
return $response;
570570
}
571571

572572
/**
@@ -576,33 +576,33 @@ public function active_before( $return, $plugin ) {
576576
*
577577
* @since 5.4.0
578578
*
579-
* @param bool|WP_Error $return Upgrade offer return.
580-
* @param array $plugin Plugin package arguments.
581-
* @return bool|WP_Error The passed in $return param or WP_Error.
579+
* @param bool|WP_Error $response The installation response after the installation has finished.
580+
* @param array $plugin Plugin package arguments.
581+
* @return bool|WP_Error The original `$response` parameter or WP_Error.
582582
*/
583-
public function active_after( $return, $plugin ) {
584-
if ( is_wp_error( $return ) ) {
585-
return $return;
583+
public function active_after( $response, $plugin ) {
584+
if ( is_wp_error( $response ) ) {
585+
return $response;
586586
}
587587

588588
// Only disable maintenance mode when in cron (background update).
589589
if ( ! wp_doing_cron() ) {
590-
return $return;
590+
return $response;
591591
}
592592

593593
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
594594

595-
// Only run if plugin is active
595+
// Only run if plugin is active.
596596
if ( ! is_plugin_active( $plugin ) ) {
597-
return $return;
597+
return $response;
598598
}
599599

600600
// Time to remove maintenance mode. Bulk edit handles this separately.
601601
if ( ! $this->bulk ) {
602602
$this->maintenance_mode( false );
603603
}
604604

605-
return $return;
605+
return $response;
606606
}
607607

608608
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,14 @@ public function install_package( $args = array() ) {
477477
$this->skin->feedback( 'installing_package' );
478478

479479
/**
480-
* Filters the install response before the installation has started.
480+
* Filters the installation response before the installation has started.
481481
*
482482
* Returning a value that could be evaluated as a `WP_Error` will effectively
483483
* short-circuit the installation, returning that value instead.
484484
*
485485
* @since 2.8.0
486486
*
487-
* @param bool|WP_Error $response Response.
487+
* @param bool|WP_Error $response Installation response.
488488
* @param array $hook_extra Extra arguments passed to hooked filters.
489489
*/
490490
$res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );

0 commit comments

Comments
 (0)