Fix a regression in wp_mkdir_p() where the $mode of the parent folder is not correctly applied to all created paths. Fixes #25822 for trunk

Built from https://develop.svn.wordpress.org/trunk@26449


git-svn-id: http://core.svn.wordpress.org/trunk@26347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-11-28 02:20:10 +00:00
parent d4d7ec693b
commit 8c60f742a1
1 changed files with 11 additions and 2 deletions

View File

@ -1383,14 +1383,23 @@ function wp_mkdir_p( $target ) {
} }
// Get the permission bits. // Get the permission bits.
if ( $target_parent && '.' != $target_parent ) { $dir_perms = false;
$stat = @stat( $target_parent ); if ( $stat = @stat( $target_parent ) ) {
$dir_perms = $stat['mode'] & 0007777; $dir_perms = $stat['mode'] & 0007777;
} else { } else {
$dir_perms = 0777; $dir_perms = 0777;
} }
if ( @mkdir( $target, $dir_perms, true ) ) { if ( @mkdir( $target, $dir_perms, true ) ) {
// If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod()
if ( $dir_perms != $dir_perms & ~umask() ) {
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
@chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
}
}
return true; return true;
} }