Make WordPress Core

Changeset 55229


Ignore:
Timestamp:
02/06/2023 02:46:01 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Send language pack updates to copy_dir().

If the clear_working flag in WP_Upgrader::install_package() is false, the source should not be removed, so copy_dir() should be used instead.

Partial updates, like language packs, may want to retain the destination. If the destination exists or has contents, this may be a partial update, and the destination should not be removed, so copy_dir() should be used instead.

Follow-up to [55204], [55219], [55220], [55223], [55226].

Props afragen, costdev, swissspidy.
See #57557.

File:
1 edited

Legend:

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

    r55220 r55229  
    589589
    590590                /*
    591                  * Partial updates may want to retain the destination.
    592                  * move_dir() returns a WP_Error when the destination exists,
    593                  * so copy_dir() should be used.
    594                  *
    595                  * If 'clear_working' is false, the source shouldn't be removed.
    596                  * After move_dir() runs, the source will no longer exist.
    597                  * Therefore, copy_dir() should be used.
     591                 * If 'clear_working' is false, the source should not be removed, so use copy_dir() instead.
     592                 *
     593                 * Partial updates, like language packs, may want to retain the destination.
     594                 * If the destination exists or has contents, this may be a partial update,
     595                 * and the destination should not be removed, so use copy_dir() instead.
    598596                 */
    599                 if ( $clear_destination && $args['clear_working'] ) {
     597                if ( $args['clear_working']
     598                        && (
     599                                // Destination does not exist or has no contents.
     600                                ! $wp_filesystem->exists( $remote_destination )
     601                                || empty( $wp_filesystem->dirlist( $remote_destination ) )
     602                        )
     603                ) {
    600604                        $result = move_dir( $source, $remote_destination, true );
    601605                } else {
Note: See TracChangeset for help on using the changeset viewer.