WordPress.org

Make WordPress Core

Ticket #51857: 51857.2.diff

File 51857.2.diff, 1.7 KB (added by afragen, 3 months ago)

only test on first pass

  • wp-admin/includes/file.php

    diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
    index 993635e460..e2e9209c84 100644
    a b function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { 
    17301730 * Assumes that WP_Filesystem() has already been called and setup.
    17311731 *
    17321732 * @since 2.5.0
     1733 * @since 5.7.0 Add $first_pass parameter.
    17331734 *
    17341735 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    17351736 *
    1736  * @param string   $from      Source directory.
    1737  * @param string   $to        Destination directory.
    1738  * @param string[] $skip_list An array of files/folders to skip copying.
     1737 * @param string   $from       Source directory.
     1738 * @param string   $to         Destination directory.
     1739 * @param string[] $skip_list  An array of files/folders to skip copying.
     1740 * @param bool     $first_pass True on the initial call, but false on subsequent calls.
    17391741 * @return true|WP_Error True on success, WP_Error on failure.
    17401742 */
    1741 function copy_dir( $from, $to, $skip_list = array() ) {
     1743function copy_dir( $from, $to, $skip_list = array(), $first_pass = true ) {
    17421744        global $wp_filesystem;
    17431745
    17441746        $dirlist = $wp_filesystem->dirlist( $from );
    17451747
     1748        if ( ! $dirlist && $first_pass ) {
     1749                return new WP_Error( 'dirlist_failed_copy_dir', __( 'Directory listing failed.' ), $wp_filesystem->method );
     1750        }
     1751
    17461752        $from = trailingslashit( $from );
    17471753        $to   = trailingslashit( $to );
    17481754
    function copy_dir( $from, $to, $skip_list = array() ) { 
    17761782                                }
    17771783                        }
    17781784
    1779                         $result = copy_dir( $from . $filename, $to . $filename, $sub_skip_list );
     1785                        $result = copy_dir( $from . $filename, $to . $filename, $sub_skip_list, false );
    17801786                        if ( is_wp_error( $result ) ) {
    17811787                                return $result;
    17821788                        }