Make use of the recursive option in mkdir() in wp_mkdir_p(). Avoids a bunch of silenced PHP Notices being logged. Fixes #23196
Built from https://develop.svn.wordpress.org/trunk@25047 git-svn-id: http://core.svn.wordpress.org/trunk@25034 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ef3b20c949
commit
5eb1c81924
|
@ -1336,19 +1336,23 @@ function wp_mkdir_p( $target ) {
|
||||||
if ( file_exists( $target ) )
|
if ( file_exists( $target ) )
|
||||||
return @is_dir( $target );
|
return @is_dir( $target );
|
||||||
|
|
||||||
// Attempting to create the directory may clutter up our display.
|
// We need to find the permissions of the parent folder that exists and inherit that.
|
||||||
if ( @mkdir( $target ) ) {
|
$target_parent = dirname( $target );
|
||||||
$stat = @stat( dirname( $target ) );
|
while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
|
||||||
$dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
|
$target_parent = dirname( $target_parent );
|
||||||
@chmod( $target, $dir_perms );
|
|
||||||
return true;
|
|
||||||
} elseif ( is_dir( dirname( $target ) ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the above failed, attempt to create the parent node, then try again.
|
// Get the permission bits.
|
||||||
if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
|
if ( $target_parent && '.' != $target_parent ) {
|
||||||
return wp_mkdir_p( $target );
|
$stat = @stat( $target_parent );
|
||||||
|
$dir_perms = $stat['mode'] & 0007777;
|
||||||
|
} else {
|
||||||
|
$dir_perms = 0777;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( @mkdir( $target, $dir_perms, true ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue