WordPress.org

Make WordPress Core

Changeset 11926


Ignore:
Timestamp:
09/13/2009 11:00:45 PM (9 years ago)
Author:
azaozz
Message:

Plugin/Theme installer: Do not bail if empty destination directory exists, props dd32, fixes #10775

File:
1 edited

Legend:

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

    r11862 r11926  
    211211        }
    212212
    213         //If we're not clearing the destination folder, and something exists there allready, Bail.
    214         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 ) {
    218             //We're going to clear the destination if theres something there
    219             $this->skin->feedback('remove_old');
    220 
    221             $removed = true;
    222             if ( $wp_filesystem->exists($remote_destination) )
     213        if ( $wp_filesystem->exists($remote_destination) ) {
     214            if ( $clear_destination ) {
     215                //We're going to clear the destination if theres something there
     216                $this->skin->feedback('remove_old');
    223217                $removed = $wp_filesystem->delete($remote_destination, true);
    224 
    225             $removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
    226 
    227             if ( is_wp_error($removed) )
    228                 return $removed;
    229             else if ( ! $removed )
    230                 return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
     218                $removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
     219
     220                if ( is_wp_error($removed) )
     221                    return $removed;
     222                else if ( ! $removed )
     223                    return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
     224            } else {
     225                //If we're not clearing the destination folder and something exists there allready, Bail.
     226                //But first check to see if there are actually any files in the folder.
     227                $_files = $wp_filesystem->dirlist($remote_destination);
     228                if ( ! empty($_files) ) {
     229                    $wp_filesystem->delete($remote_source, true); //Clear out the source files.
     230                    return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
     231                }
     232            }
    231233        }
    232234
Note: See TracChangeset for help on using the changeset viewer.