Ticket #23196: 23196.diff
| File 23196.diff, 1.7 KB (added by , 13 years ago) |
|---|
-
wp-includes/functions.php
1316 1316 $wrapper = null; 1317 1317 1318 1318 // strip the protocol 1319 if ( wp_is_stream( $target ) ) {1319 if ( wp_is_stream( $target ) ) { 1320 1320 list( $wrapper, $target ) = explode( '://', $target, 2 ); 1321 1321 } 1322 1322 … … 1324 1324 $target = str_replace( '//', '/', $target ); 1325 1325 1326 1326 // put the wrapper back on the target 1327 if ( $wrapper !== null ) {1327 if ( $wrapper !== null ) { 1328 1328 $target = $wrapper . '://' . $target; 1329 1329 } 1330 1330 … … 1336 1336 if ( file_exists( $target ) ) 1337 1337 return @is_dir( $target ); 1338 1338 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 = 0700; 1351 } 1352 1353 if ( @mkdir( $target, $dir_perms, true ) ) { 1344 1354 return true; 1345 } elseif ( is_dir( dirname( $target ) ) ) {1346 return false;1347 1355 } 1348 1356 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 );1352 1353 1357 return false; 1354 1358 } 1355 1359