Make WordPress Core

Ticket #57375: 57375.diff

File 57375.diff, 1.2 KB (added by SergeyBiryukov, 2 years ago)
  • src/wp-admin/includes/file.php

     
    19711971        global $wp_filesystem;
    19721972
    19731973        if ( trailingslashit( strtolower( $from ) ) === trailingslashit( strtolower( $to ) ) ) {
    1974                 return new WP_Error(
    1975                         'source_destination_same_move_dir',
    1976                         __( 'The source and destination are the same.' )
    1977                 );
     1974                return new WP_Error( 'source_destination_same_move_dir', __( 'The source and destination are the same.' ) );
    19781975        }
    19791976
    1980         if ( ! $overwrite && $wp_filesystem->exists( $to ) ) {
     1977        $destination_exists = $wp_filesystem->exists( $to );
     1978
     1979        if ( ! $overwrite && $destination_exists ) {
    19811980                return new WP_Error( 'destination_already_exists_move_dir', __( 'The destination folder already exists.' ), $to );
    19821981        }
    19831982
    1984         if ( $overwrite && $wp_filesystem->exists( $to ) && ! $wp_filesystem->delete( $to, true ) ) {
     1983        if ( $overwrite && $destination_exists && ! $wp_filesystem->delete( $to, true ) ) {
    19851984                // Can't overwrite if the destination couldn't be deleted.
    19861985                return WP_Error( 'destination_not_deleted_move_dir', __( 'The destination directory already exists and could not be removed.' ) );
    19871986        }