WordPress.org

Make WordPress Core

Ticket #10775: 10775.diff

File 10775.diff, 1.1 KB (added by dd32, 6 years ago)
  • wp-admin/includes/class-wp-upgrader.php

     
    212212 
    213213                //If we're not clearing the destination folder, and something exists there allready, Bail. 
    214214                if ( ! $clear_destination && $wp_filesystem->exists($remote_destination) ) { 
    215                         $wp_filesystem->delete($remote_source, true); //Clear out the source files. 
    216                         return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination ); 
    217                 } else if ( $clear_destination ) { 
     215                        //Check to see if there are actually any files in the folder before bailing 
     216                        $_files = $wp_filesystem->dirlist($remote_destination); 
     217                        if ( ! empty($_files) ) { 
     218                                $wp_filesystem->delete($remote_source, true); //Clear out the source files. 
     219                                return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination ); 
     220                        } 
     221                } 
     222                if ( $clear_destination ) { 
    218223                        //We're going to clear the destination if theres something there 
    219224                        $this->skin->feedback('remove_old'); 
    220225