]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/functions.php
WordPress 3.7.2
[autoinstalls/wordpress.git] / wp-includes / functions.php
index aea813b7d007880cd447594a51bae0832ff543d0..c9db0910090a0f7e673047803d24acedcbbb9f0b 100644 (file)
@@ -1372,14 +1372,23 @@ function wp_mkdir_p( $target ) {
        }
 
        // Get the permission bits.
-       if ( $target_parent && '.' != $target_parent ) {
-               $stat = @stat( $target_parent );
+       $dir_perms = false;
+       if ( $stat = @stat( $target_parent ) ) {
                $dir_perms = $stat['mode'] & 0007777;
        } else {
                $dir_perms = 0777;
        }
 
        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;
        }