* $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 );
}
* @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;
$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 '';
}
}
if ( $logMsg !== false ) {
- wfDebugLog( 'exec', "$logMsg: $cmd\n" );
+ wfDebugLog( 'exec', "$logMsg: $cmd" );
}
return $outBuffer;
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
# 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(
$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 );