mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-05 01:30:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55938 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1910,6 +1910,14 @@ function copy_dir( $from, $to, $skip_list = array() ) {
|
||||
$from = trailingslashit( $from );
|
||||
$to = trailingslashit( $to );
|
||||
|
||||
if ( ! $wp_filesystem->exists( $to ) && ! $wp_filesystem->mkdir( $to ) ) {
|
||||
return new WP_Error(
|
||||
'mkdir_destination_failed_copy_dir',
|
||||
__( 'Could not create the destination directory.' ),
|
||||
basename( $to )
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( (array) $dirlist as $filename => $fileinfo ) {
|
||||
if ( in_array( $filename, $skip_list, true ) ) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user