Alrighty, now we properly remove old blocks before inserting the new one. (Bug 10080...
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 6bd1fb8..5069212 100644 (file)
@@ -176,12 +176,16 @@ function wfDebug( $text, $logonly = false ) {
        global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage;
        static $recursion = 0;
 
+       static $cache = array(); // Cache of unoutputted messages
+
        # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
        if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) {
                return;
        }
 
        if ( $wgDebugComments && !$logonly ) {
+               $cache[] = $text;
+
                if ( !isset( $wgOut ) ) {
                        return;
                }
@@ -193,7 +197,10 @@ function wfDebug( $text, $logonly = false ) {
                        $wgOut->_unstub();
                        $recursion--;
                }
-               $wgOut->debug( $text );
+
+               // add the message and possible cached ones to the output
+               array_map( array( $wgOut, 'debug' ), $cache );
+               $cache = array();
        }
        if ( '' != $wgDebugLogFile && !$wgProfileOnly ) {
                # Strip unprintables; they can switch terminal modes when binary data
@@ -587,7 +594,8 @@ function wfMsgExt( $key, $options ) {
                $langCode = $options['language'];
                $validCodes = array_keys( Language::getLanguageNames() );
                if( !in_array($options['language'], $validCodes) ) {
-                       $langCode = false;
+                       # Fallback to en, instead of whatever interface language we might have
+                       $langCode = 'en';
                }
        } else {
                $forContent = false;
@@ -1730,16 +1738,22 @@ function wfMkdirParents( $fullDir, $mode = 0777 ) {
                return true;
        } elseif ( $currentDir === false ) {
                # Went all the way back to root and it apparently doesn't exist
+               wfDebugLog( 'mkdir', "Root doesn't exist?\n" );
                return false;
        }
-       
        # Now go forward creating directories
        $createList = array_reverse( $createList );
+
+       # Is the parent directory writable?
+       if ( $currentDir === '' ) {
+               $currentDir = '/';
+       }
+       if ( !is_writable( $currentDir ) ) {
+               wfDebugLog( 'mkdir', "Not writable: $currentDir\n" );
+               return false;
+       }
+       
        foreach ( $createList as $dir ) {
-               # Check first to avoid spamming with warnings
-               if ( !is_writable( $dir ) ) {
-                       return false;
-               }
                # use chmod to override the umask, as suggested by the PHP manual
                if ( !mkdir( $dir, $mode ) || !chmod( $dir, $mode ) ) {
                        wfDebugLog( 'mkdir', "Unable to create directory $dir\n" );
@@ -1787,23 +1801,6 @@ function wfPercent( $nr, $acc = 2, $round = true ) {
        return $round ? round( $ret, $acc ) . '%' : "$ret%";
 }
 
-/**
- * Encrypt a username/password.
- *
- * @param string $userid ID of the user
- * @param string $password Password of the user
- * @return string Hashed password
- */
-function wfEncryptPassword( $userid, $password ) {
-       global $wgPasswordSalt;
-       $p = md5( $password);
-
-       if($wgPasswordSalt)
-               return md5( "{$userid}-{$p}" );
-       else
-               return $p;
-}
-
 /**
  * Appends to second array if $value differs from that in $default
  */