Make WordPress Core

Changeset 60997


Ignore:
Timestamp:
10/20/2025 11:35:29 PM (3 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use more meaningful variable names in Plugin Upgrader.

Per the Naming Conventions:

Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

This commit includes renaming of the following variables:

  • $r to $upgrade_data.
  • $res to $connected.
  • $pluginfiles to $plugin_files — Per naming conventions, separate words via underscores.
  • $info to $new_plugin_data.

Follow-up to [6779], [8550], [9141], [11005], [12157], [18618], [56525].

Props costdev, mukesh27.
See #63168.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-plugin-upgrader.php

    r59159 r60997  
    207207
    208208        // Get the URL to the zip file.
    209         $r = $current->response[ $plugin ];
     209        $upgrade_data = $current->response[ $plugin ];
    210210
    211211        add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
     
    224224        $this->run(
    225225            array(
    226                 'package'           => $r->package,
     226                'package'           => $upgrade_data->package,
    227227                'destination'       => WP_PLUGIN_DIR,
    228228                'clear_destination' => true,
     
    302302
    303303        // Connect to the filesystem first.
    304         $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
    305         if ( ! $res ) {
     304        $connected = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
     305        if ( ! $connected ) {
    306306            $this->skin->footer();
    307307            return false;
     
    342342
    343343            // Get the URL to the zip file.
    344             $r = $current->response[ $plugin ];
     344            $upgrade_data = $current->response[ $plugin ];
    345345
    346346            $this->skin->plugin_active = is_plugin_active( $plugin );
    347347
    348             if ( isset( $r->requires ) && ! is_wp_version_compatible( $r->requires ) ) {
     348            if ( isset( $upgrade_data->requires ) && ! is_wp_version_compatible( $upgrade_data->requires ) ) {
    349349                $result = new WP_Error(
    350350                    'incompatible_wp_required_version',
     
    353353                        __( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
    354354                        $wp_version,
    355                         $r->requires
     355                        $upgrade_data->requires
    356356                    )
    357357                );
     
    360360                $this->skin->error( $result );
    361361                $this->skin->after();
    362             } elseif ( isset( $r->requires_php ) && ! is_php_version_compatible( $r->requires_php ) ) {
     362            } elseif ( isset( $upgrade_data->requires_php ) && ! is_php_version_compatible( $upgrade_data->requires_php ) ) {
    363363                $result = new WP_Error(
    364364                    'incompatible_php_required_version',
     
    367367                        __( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
    368368                        PHP_VERSION,
    369                         $r->requires_php
     369                        $upgrade_data->requires_php
    370370                    )
    371371                );
     
    378378                $result = $this->run(
    379379                    array(
    380                         'package'           => $r->package,
     380                        'package'           => $upgrade_data->package,
    381381                        'destination'       => WP_PLUGIN_DIR,
    382382                        'clear_destination' => true,
     
    479479        if ( $files ) {
    480480            foreach ( $files as $file ) {
    481                 $info = get_plugin_data( $file, false, false );
    482                 if ( ! empty( $info['Name'] ) ) {
    483                     $this->new_plugin_data = $info;
     481                $new_plugin_data = get_plugin_data( $file, false, false );
     482                if ( ! empty( $new_plugin_data['Name'] ) ) {
     483                    $this->new_plugin_data = $new_plugin_data;
    484484                    break;
    485485                }
     
    491491        }
    492492
    493         $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
    494         $requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;
     493        $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
     494        $requires_wp  = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
    495495
    496496        if ( ! is_php_version_compatible( $requires_php ) ) {
     
    543543
    544544        // Assume the requested plugin is the first in the list.
    545         $pluginfiles = array_keys( $plugin );
    546 
    547         return $this->result['destination_name'] . '/' . $pluginfiles[0];
     545        $plugin_files = array_keys( $plugin );
     546
     547        return $this->result['destination_name'] . '/' . $plugin_files[0];
    548548    }
    549549
Note: See TracChangeset for help on using the changeset viewer.