WordPress.org

Make WordPress Core

Ticket #14781: 14781.4.diff

File 14781.4.diff, 1.5 KB (added by pbiron, 5 months ago)

refreshing patch

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

    From fdaad3470b6a2ad6d391721ccd220bf0a30b97be Mon Sep 17 00:00:00 2001
    From: Paul Biron <paul@sparrowhawkcomputing.com>
    Date: Thu, 6 May 2021 18:06:18 -0600
    Subject: [PATCH] Refresh patch.
    
    ---
     src/wp-admin/includes/class-wp-upgrader.php | 22 ++++++++++++++++-----
     1 file changed, 17 insertions(+), 5 deletions(-)
    
    diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php
    index e456191dae..62b84d053b 100644
    a b class WP_Upgrader { 
    324324                        $wp_filesystem->delete( $working_dir, true );
    325325                }
    326326
    327                 // Unzip package to working directory.
    328                 $result = unzip_file( $package, $working_dir );
     327                $extension = pathinfo( $package, PATHINFO_EXTENSION );
     328                if ( $extension == 'zip' ) {
     329                        // Unzip package to working directory.
     330                        $result = unzip_file( $package, $working_dir );
     331
     332                        // Once extracted, delete the package if required.
     333                        if ( $delete_package ) {
     334                                unlink( $package );
     335                        }
     336                } else {
     337                        // Create a new folder for the PHP file
     338                        mkdir( $working_dir );
    329339
    330                 // Once extracted, delete the package if required.
    331                 if ( $delete_package ) {
    332                         unlink( $package );
     340                        // Copy the PHP file into the new foler.
     341                        if ( ! rename( $package, $working_dir . '/' . basename( $package ) ) ) {
     342                                $error  = error_get_last();
     343                                $result = new WP_Error( 'rename_failed', $error['message'] );
     344                        }
    333345                }
    334346
    335347                if ( is_wp_error( $result ) ) {