Make WordPress Core

Ticket #41524: 41524.diff

File 41524.diff, 1.2 KB (added by johnbillion, 7 years ago)
  • src/wp-admin/includes/class-wp-upgrader.php

    diff --git src/wp-admin/includes/class-wp-upgrader.php src/wp-admin/includes/class-wp-upgrader.php
    index 6ee7684c35..a2687b0a02 100644
    class WP_Upgrader { 
    343343                $unwritable_files = array();
    344344
    345345                $_files = $wp_filesystem->dirlist( $remote_destination, true, true );
     346                $_flat_files = array();
    346347
    347                 // Flatten the resulting array, iterate using each as we append to the array during iteration.
    348                 while ( $f = each( $_files ) ) {
    349                         $file = $f['value'];
    350                         $name = $f['key'];
     348                // @TODO needs testing:
    351349
     350                // Flatten the resulting array.
     351                foreach ( $_files as $name => $file ) {
    352352                        if ( ! isset( $file['files'] ) ) {
    353353                                continue;
    354354                        }
    355355
    356356                        foreach ( $file['files'] as $filename => $details ) {
    357                                 $_files[ $name . '/' . $filename ] = $details;
     357                                $_flat_files[ $name . '/' . $filename ] = $details;
    358358                        }
    359359                }
    360360
    361361                // Check writability.
    362                 foreach ( $_files as $filename => $file_details ) {
     362                foreach ( $_flat_files as $filename => $file_details ) {
    363363                        if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
    364364
    365365                                // Attempt to alter permissions to allow writes and try again.