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:
Dion Hulse 2013-08-17 03:09:11 +00:00
parent ef3b20c949
commit 5eb1c81924
1 changed files with 15 additions and 11 deletions

View File

@ -1336,19 +1336,23 @@ function wp_mkdir_p( $target ) {
if ( file_exists( $target ) )
return @is_dir( $target );
// Attempting to create the directory may clutter up our display.
if ( @mkdir( $target ) ) {
$stat = @stat( dirname( $target ) );
$dir_perms = $stat['mode'] & 0007777; // Get the permission bits.
@chmod( $target, $dir_perms );
return true;
} elseif ( is_dir( dirname( $target ) ) ) {
return false;
// We need to find the permissions of the parent folder that exists and inherit that.
$target_parent = dirname( $target );
while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
$target_parent = dirname( $target_parent );
}
// If the above failed, attempt to create the parent node, then try again.
if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
return wp_mkdir_p( $target );
// Get the permission bits.
if ( $target_parent && '.' != $target_parent ) {
$stat = @stat( $target_parent );
$dir_perms = $stat['mode'] & 0007777;
} else {
$dir_perms = 0777;
}
if ( @mkdir( $target, $dir_perms, true ) ) {
return true;
}
return false;
}