Make WordPress Core

Changeset 25047


Ignore:
Timestamp:
08/17/2013 03:08:50 AM (13 years ago)
Author:
dd32
Message:

Make use of the recursive option in mkdir() in wp_mkdir_p(). Avoids a bunch of silenced PHP Notices being logged. Fixes #23196

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r25037 r25047  
    13371337                return @is_dir( $target );
    13381338
    1339         // Attempting to create the directory may clutter up our display.
    1340         if ( @mkdir( $target ) ) {
    1341                 $stat = @stat( dirname( $target ) );
    1342                 $dir_perms = $stat['mode'] & 0007777;  // Get the permission bits.
    1343                 @chmod( $target, $dir_perms );
     1339        // We need to find the permissions of the parent folder that exists and inherit that.
     1340        $target_parent = dirname( $target );
     1341        while ( '.' != $target_parent && ! is_dir( $target_parent ) ) {
     1342                $target_parent = dirname( $target_parent );
     1343        }
     1344
     1345        // Get the permission bits.
     1346        if ( $target_parent && '.' != $target_parent ) {
     1347                $stat = @stat( $target_parent );
     1348                $dir_perms = $stat['mode'] & 0007777;
     1349        } else {
     1350                $dir_perms = 0777;
     1351        }
     1352
     1353        if ( @mkdir( $target, $dir_perms, true ) ) {
    13441354                return true;
    1345         } elseif ( is_dir( dirname( $target ) ) ) {
    1346                         return false;
    1347         }
    1348 
    1349         // If the above failed, attempt to create the parent node, then try again.
    1350         if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
    1351                 return wp_mkdir_p( $target );
     1355        }
    13521356
    13531357        return false;
Note: See TracChangeset for help on using the changeset viewer.