Make WordPress Core

Ticket #38946: 38946.patch

File 38946.patch, 4.9 KB (added by shivapoudel, 8 years ago)

Fix for 38946

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

     
    397397        /**
    398398         * Install a package.
    399399         *
    400          * Copies the contents of a package form a source directory, and installs them in
     400         * Copies the contents of a package from a source directory, and installs them in
    401401         * a destination directory. Optionally removes the source. It can also optionally
    402402         * clear out the destination folder if it already exists.
    403403         *
     
    415415         *                                               Default empty.
    416416         *     @type bool   $clear_destination           Whether to delete any files already in the destination
    417417         *                                               folder. Default false.
    418          *     @type bool   $clear_working               Whether to delete the files form the working directory
     418         *     @type bool   $clear_working               Whether to delete the files from the working directory
    419419         *                                               after copying to the destination. Default false.
     420         *     @type bool   $protect_destination         Whether to protect against deleting any files already
     421         *                                               in the destination folder. Default false.
    420422         *     @type bool   $abort_if_destination_exists Whether to abort the installation if
    421423         *                                               the destination folder already exists. Default true.
    422424         *     @type array  $hook_extra                  Extra arguments to pass to the filter hooks called by
     
    433435                        'destination' => '', // and this
    434436                        'clear_destination' => false,
    435437                        'clear_working' => false,
     438                        'protect_destination' => false,
    436439                        'abort_if_destination_exists' => true,
    437440                        'hook_extra' => array()
    438441                );
     
    520523                        $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
    521524                }
    522525
    523                 if ( in_array( $destination, $protected_directories ) ) {
     526                if ( in_array( $destination, $protected_directories ) || $args['protect_destination'] ) {
    524527                        $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
    525528                        $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
    526529                }
     
    621624         *                                               Default empty.
    622625         *     @type bool   $clear_destination           Whether to delete any files already in the
    623626         *                                               destination folder. Default false.
    624          *     @type bool   $clear_working               Whether to delete the files form the working
     627         *     @type bool   $clear_working               Whether to delete the files from the working
    625628         *                                               directory after copying to the destination.
    626629         *                                               Default false.
     630         *     @type bool   $protect_destination         Whether to protect against deleting any files already
     631         *                                               in the destination folder. Default false.
    627632         *     @type bool   $abort_if_destination_exists Whether to abort the installation if the destination
    628633         *                                               folder already exists. When true, `$clear_destination`
    629634         *                                               should be false. Default true.
     
    643648                        'package' => '', // Please always pass this.
    644649                        'destination' => '', // And this
    645650                        'clear_destination' => false,
     651                        'clear_working' => true,
     652                        'protect_destination' => false,
    646653                        'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
    647                         'clear_working' => true,
    648654                        'is_multi' => false,
    649655                        'hook_extra' => array() // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
    650656                );
     
    665671                 *     @type string $destination                 Update location.
    666672                 *     @type bool   $clear_destination           Clear the destination resource.
    667673                 *     @type bool   $clear_working               Clear the working resource.
     674                 *     @type bool   $protect_destination         Protect the destination resource.
    668675                 *     @type bool   $abort_if_destination_exists Abort if the Destination directory exists.
    669676                 *     @type bool   $is_multi                    Whether the upgrader is running multiple times.
    670677                 *     @type array  $hook_extra {
     
    740747                        'source' => $working_dir,
    741748                        'destination' => $options['destination'],
    742749                        'clear_destination' => $options['clear_destination'],
     750                        'clear_working' => $options['clear_working'],
     751                        'protect_destination' => $options['protect_destination'],
    743752                        'abort_if_destination_exists' => $options['abort_if_destination_exists'],
    744                         'clear_working' => $options['clear_working'],
    745753                        'hook_extra' => $options['hook_extra']
    746754                ) );
    747755