Make WordPress Core


Ignore:
Timestamp:
06/19/2023 01:58:25 AM (18 months ago)
Author:
peterwilsoncc
Message:

Filesystem API: Attempt to create directory in copy_dir().

Adds a check to the start of copy_dir() that the destination directory exists and attempts to create it if it does not.

An error is returned if the directory can not be created, either due to a permissions error or the parent directory not existing.

Props caraffande, costdev, zunaid321.
Fixes #41855.

File:
1 edited

Legend:

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

    r55872 r55938  
    19111911    $to   = trailingslashit( $to );
    19121912
     1913    if ( ! $wp_filesystem->exists( $to ) && ! $wp_filesystem->mkdir( $to ) ) {
     1914        return new WP_Error(
     1915            'mkdir_destination_failed_copy_dir',
     1916            __( 'Could not create the destination directory.' ),
     1917            basename( $to )
     1918        );
     1919    }
     1920
    19131921    foreach ( (array) $dirlist as $filename => $fileinfo ) {
    19141922        if ( in_array( $filename, $skip_list, true ) ) {
Note: See TracChangeset for help on using the changeset viewer.