Remove $wgHttpOnlyBlacklist
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 2dda695..61d1a70 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,19 +1031,42 @@ 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 ( $logConfig === false ) {
+               return;
+       }
        if ( is_array( $logConfig ) ) {
                if ( isset( $logConfig['sample'] ) && mt_rand( 1, $logConfig['sample'] ) !== 1 ) {
                        return;
@@ -2836,7 +2871,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 '';
        }
@@ -2951,7 +2986,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(),
        }
 
        if ( $logMsg !== false ) {
-               wfDebugLog( 'exec', "$logMsg: $cmd\n" );
+               wfDebugLog( 'exec', "$logMsg: $cmd" );
        }
 
        return $outBuffer;
@@ -3408,23 +3443,6 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1,
        return str_pad( $result, $pad, '0', STR_PAD_LEFT );
 }
 
-/**
- * @return bool
- */
-function wfHttpOnlySafe() {
-       global $wgHttpOnlyBlacklist;
-
-       if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
-               foreach ( $wgHttpOnlyBlacklist as $regex ) {
-                       if ( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) {
-                               return false;
-                       }
-               }
-       }
-
-       return true;
-}
-
 /**
  * Check if there is sufficient entropy in php's built-in session generation
  * @return bool true = there is sufficient entropy
@@ -3497,7 +3515,6 @@ function wfSetupSession( $sessionId = false ) {
                # hasn't already been set to the desired value (that causes errors)
                ini_set( 'session.save_handler', $wgSessionHandler );
        }
-       $httpOnlySafe = wfHttpOnlySafe() && $wgCookieHttpOnly;
        wfDebugLog( 'cookie',
                'session_set_cookie_params: "' . implode( '", "',
                        array(
@@ -3505,8 +3522,9 @@ function wfSetupSession( $sessionId = false ) {
                                $wgCookiePath,
                                $wgCookieDomain,
                                $wgCookieSecure,
-                               $httpOnlySafe ) ) . '"' );
-       session_set_cookie_params( 0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $httpOnlySafe );
+                               $wgCookieHttpOnly ) ) . '"' );
+       session_set_cookie_params(
+               0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly );
        session_cache_limiter( 'private, must-revalidate' );
        if ( $sessionId ) {
                session_id( $sessionId );