Make WordPress Core


Ignore:
Timestamp:
11/30/2021 07:10:31 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Make some adjustments to the move_dir() function:

  • Check for direct PHP flle access and only use rename() if true.
  • Check whether the destination directory was successfully created.
  • Clear the working directory so there is internal parity within the function between the results of a successful rename() and a fallback to copy_dir().
  • Use move_dir() in WP_Upgrader::move_to_temp_backup_dir() and ::restore_temp_backup().

Follow-up to [51815], [51898], [51899], [51902], [52192], [52284].

Props afragen, peterwilsoncc, dd32, SergeyBiryukov.
See #54166, #51857.

File:
1 edited

Legend:

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

    r52284 r52289  
    629629
    630630        // Move new version of item into place.
    631         $result = move_dir( $source, $remote_destination );
     631        $result = move_dir( $source, $remote_destination, $remote_source );
    632632        if ( is_wp_error( $result ) ) {
    633633            if ( $args['clear_working'] ) {
     
    637637        }
    638638
    639         // Clear the working folder?
     639        // Clear the working directory?
    640640        if ( $args['clear_working'] ) {
    641641            $wp_filesystem->delete( $remote_source, true );
     
    10481048
    10491049        // Move to the temp-backup directory.
    1050         if ( ! $wp_filesystem->move( $src, $dest, true ) ) {
     1050        if ( ! move_dir( $src, $dest ) ) {
    10511051            return new WP_Error( 'fs_temp_backup_move', $this->strings['temp_backup_move_failed'] );
    10521052        }
     
    10821082
    10831083            // Move it.
    1084             if ( ! $wp_filesystem->move( $src, $dest, true ) ) {
     1084            if ( ! move_dir( $src, $dest ) ) {
    10851085                return new WP_Error( 'fs_temp_backup_delete', $this->strings['temp_backup_restore_failed'] );
    10861086            }
Note: See TracChangeset for help on using the changeset viewer.