r23386 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23385‎ | r23386 | r23387 >
Date:12:58, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Good old PHP 5, and the $recursive parameter to mkdir()
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1663,47 +1663,9 @@
16641664 * Make directory, and make all parent directories if they don't exist
16651665 */
16661666 function wfMkdirParents( $fullDir, $mode = 0777 ) {
1667 - if ( strval( $fullDir ) === '' ) {
 1667+ if( strval( $fullDir ) === '' )
16681668 return true;
1669 - }
1670 -
1671 - # Go back through the paths to find the first directory that exists
1672 - $currentDir = $fullDir;
1673 - $createList = array();
1674 - while ( strval( $currentDir ) !== '' && !file_exists( $currentDir ) ) {
1675 - # Strip trailing slashes
1676 - $currentDir = rtrim( $currentDir, '/\\' );
1677 -
1678 - # Add to create list
1679 - $createList[] = $currentDir;
1680 -
1681 - # Find next delimiter searching from the end
1682 - $p = max( strrpos( $currentDir, '/' ), strrpos( $currentDir, '\\' ) );
1683 - if ( $p === false ) {
1684 - $currentDir = false;
1685 - } else {
1686 - $currentDir = substr( $currentDir, 0, $p );
1687 - }
1688 - }
1689 -
1690 - if ( count( $createList ) == 0 ) {
1691 - # Directory specified already exists
1692 - return true;
1693 - } elseif ( $currentDir === false ) {
1694 - # Went all the way back to root and it apparently doesn't exist
1695 - return false;
1696 - }
1697 -
1698 - # Now go forward creating directories
1699 - $createList = array_reverse( $createList );
1700 - foreach ( $createList as $dir ) {
1701 - # use chmod to override the umask, as suggested by the PHP manual
1702 - if ( !mkdir( $dir, $mode ) || !chmod( $dir, $mode ) ) {
1703 - wfDebugLog( 'mkdir', "Unable to create directory $dir\n" );
1704 - return false;
1705 - }
1706 - }
1707 - return true;
 1669+ return mkdir( $fullDir, $mode, true );
17081670 }
17091671
17101672 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r23407Merged revisions 23203-23405 via svnmerge from...david23:00, 25 June 2007

Status & tagging log