Used DIRECTORY_SEPARATOR instead of '/' in GitInfo.php
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index a638287..6785d0c 100644 (file)
@@ -924,21 +924,33 @@ function wfMatchesDomainList( $url, $domains ) {
  * $wgDebugComments - if on, some debug items may appear in comments in the HTML output.
  *
  * @param $text String
- * @param bool $logonly set true to avoid appearing in HTML when $wgDebugComments is set
- */
-function wfDebug( $text, $logonly = false ) {
+ * @param string|bool $dest Destination of the message:
+ *     - 'all': both to the log and HTML (debug toolbar or HTML comments)
+ *     - 'log': only to the log and not in HTML
+ *   For backward compatibility, it can also take a boolean:
+ *     - true: same as 'all'
+ *     - false: same as 'log'
+ */
+function wfDebug( $text, $dest = 'all' ) {
        global $wgDebugLogFile, $wgProfileOnly, $wgDebugRawPage, $wgDebugLogPrefix;
 
        if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
                return;
        }
 
+       // Turn $dest into a string if it's a boolean (for b/c)
+       if ( $dest === true ) {
+               $dest = 'all';
+       } elseif ( $dest === false ) {
+               $dest = 'log';
+       }
+
        $timer = wfDebugTimer();
        if ( $timer !== '' ) {
                $text = preg_replace( '/[^\n]/', $timer . '\0', $text, 1 );
        }
 
-       if ( !$logonly ) {
+       if ( $dest === 'all' ) {
                MWDebug::debugMsg( $text );
        }
 
@@ -1019,18 +1031,38 @@ function wfDebugMem( $exact = false ) {
  * @param $text String
  * @param bool $public whether to log the event in the public log if no private
  *                     log file is specified, (default true)
- */
-function wfDebugLog( $logGroup, $text, $public = true ) {
+ * @param string|bool $dest Destination of the message:
+ *     - 'all': both to the log and HTML (debug toolbar or HTML comments)
+ *     - 'log': only to the log and not in HTML
+ *     - 'private': only to the specifc log if set in $wgDebugLogGroups and
+ *       discarded otherwise
+ *   For backward compatibility, it can also take a boolean:
+ *     - true: same as 'all'
+ *     - false: same as 'private'
+ */
+function wfDebugLog( $logGroup, $text, $dest = 'all' ) {
        global $wgDebugLogGroups;
+
        $text = trim( $text ) . "\n";
 
+       // Turn $dest into a string if it's a boolean (for b/c)
+       if ( $dest === true ) {
+               $dest = 'all';
+       } elseif ( $dest === false ) {
+               $dest = 'private';
+       }
+
        if ( !isset( $wgDebugLogGroups[$logGroup] ) ) {
-               if ( $public === true ) {
-                       wfDebug( "[$logGroup] $text", false );
+               if ( $dest !== 'private' ) {
+                       wfDebug( "[$logGroup] $text", $dest );
                }
                return;
        }
 
+       if ( $dest === 'all' ) {
+               MWDebug::debugMsg( "[$logGroup] $text" );
+       }
+
        $logConfig = $wgDebugLogGroups[$logGroup];
        if ( is_array( $logConfig ) ) {
                if ( isset( $logConfig['sample'] ) && mt_rand( 1, $logConfig['sample'] ) !== 1 ) {
@@ -1340,19 +1372,6 @@ function wfGetLangObj( $langcode = false ) {
        return $wgContLang;
 }
 
-/**
- * Old function when $wgBetterDirectionality existed
- * All usage removed, wfUILang can be removed in near future
- *
- * @deprecated since 1.18
- * @return Language
- */
-function wfUILang() {
-       wfDeprecated( __METHOD__, '1.18' );
-       global $wgLang;
-       return $wgLang;
-}
-
 /**
  * This is the function for getting translated interface messages.
  *
@@ -2619,25 +2638,6 @@ function wfPercent( $nr, $acc = 2, $round = true ) {
        return $round ? round( $ret, $acc ) . '%' : "$ret%";
 }
 
-/**
- * Find out whether or not a mixed variable exists in a string
- *
- * @deprecated Just use str(i)pos
- * @param $needle String
- * @param $str String
- * @param $insensitive Boolean
- * @return Boolean
- */
-function in_string( $needle, $str, $insensitive = false ) {
-       wfDeprecated( __METHOD__, '1.21' );
-       $func = 'strpos';
-       if ( $insensitive ) {
-               $func = 'stripos';
-       }
-
-       return $func( $str, $needle ) !== false;
-}
-
 /**
  * Safety wrapper around ini_get() for boolean settings.
  * The values returned from ini_get() are pre-normalized for settings
@@ -2868,7 +2868,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(),
        $pipes = null;
        $proc = proc_open( $cmd, $desc, $pipes );
        if ( !$proc ) {
-               wfDebugLog( 'exec', "proc_open() failed: $cmd\n" );
+               wfDebugLog( 'exec', "proc_open() failed: $cmd" );
                $retval = -1;
                return '';
        }
@@ -2983,7 +2983,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(),
        }
 
        if ( $logMsg !== false ) {
-               wfDebugLog( 'exec', "$logMsg: $cmd\n" );
+               wfDebugLog( 'exec', "$logMsg: $cmd" );
        }
 
        return $outBuffer;
@@ -3712,15 +3712,6 @@ function wfLocalFile( $title ) {
        return RepoGroup::singleton()->getLocalRepo()->newFile( $title );
 }
 
-/**
- * Stream a file to the browser. Back-compat alias for StreamFile::stream()
- * @deprecated since 1.19
- */
-function wfStreamFile( $fname, $headers = array() ) {
-       wfDeprecated( __FUNCTION__, '1.19' );
-       StreamFile::stream( $fname, $headers );
-}
-
 /**
  * Should low-performance queries be disabled?
  *
@@ -3848,23 +3839,6 @@ function wfCountDown( $n ) {
        echo "\n";
 }
 
-/**
- * Generate a random 32-character hexadecimal token.
- * @param $salt Mixed: some sort of salt, if necessary, to add to random
- *              characters before hashing.
- * @return string
- * @codeCoverageIgnore
- * @deprecated since 1.20; Please use MWCryptRand for security purposes and
- * wfRandomString for pseudo-random strings
- * @warning This method is NOT secure. Additionally it has many callers that
- * use it for pseudo-random purposes.
- */
-function wfGenerateToken( $salt = '' ) {
-       wfDeprecated( __METHOD__, '1.20' );
-       $salt = serialize( $salt );
-       return md5( mt_rand( 0, 0x7fffffff ) . $salt );
-}
-
 /**
  * Replace all invalid characters with -
  * Additional characters can be defined in $wgIllegalFileChars (see bug 20489)