Make WordPress Core

Changeset 27887 for branches/3.7


Ignore:
Timestamp:
04/01/2014 04:01:10 AM (10 years ago)
Author:
nacin
Message:

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

Merges [26449] and [26927] from 3.8.x to the 3.7 branch.

props dd32.
fixes #25822.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-includes/functions.php

    r25827 r27887  
    13731373
    13741374    // Get the permission bits.
    1375     if ( $target_parent && '.' != $target_parent ) {
    1376         $stat = @stat( $target_parent );
     1375    $dir_perms = false;
     1376    if ( $stat = @stat( $target_parent ) ) {
    13771377        $dir_perms = $stat['mode'] & 0007777;
    13781378    } else {
     
    13811381
    13821382    if ( @mkdir( $target, $dir_perms, true ) ) {
     1383
     1384        // If a umask is set that modifies $dir_perms, we'll have to re-set the $dir_perms correctly with chmod()
     1385        if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
     1386            $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
     1387            for ( $i = 1; $i <= count( $folder_parts ); $i++ ) {
     1388                @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
     1389            }
     1390        }
     1391
    13831392        return true;
    13841393    }
Note: See TracChangeset for help on using the changeset viewer.