Make DjVu metadata be stored as serialized PHP array.
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 3727f16..cef19e1 100644 (file)
@@ -921,7 +921,6 @@ function wfMatchesDomainList( $url, $domains ) {
  *
  * Controlling globals:
  * $wgDebugLogFile - points to the log file
- * $wgProfileOnly - if set, normal debug messages will not be recorded.
  * $wgDebugRawPage - if false, 'action=raw' hits will not result in debug output.
  * $wgDebugComments - if on, some debug items may appear in comments in the HTML output.
  *
@@ -934,7 +933,7 @@ function wfMatchesDomainList( $url, $domains ) {
  *     - false: same as 'log'
  */
 function wfDebug( $text, $dest = 'all' ) {
-       global $wgDebugLogFile, $wgProfileOnly, $wgDebugRawPage, $wgDebugLogPrefix;
+       global $wgDebugLogFile, $wgDebugRawPage, $wgDebugLogPrefix;
 
        if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
                return;
@@ -956,7 +955,7 @@ function wfDebug( $text, $dest = 'all' ) {
                MWDebug::debugMsg( $text );
        }
 
-       if ( $wgDebugLogFile != '' && !$wgProfileOnly ) {
+       if ( $wgDebugLogFile != '' ) {
                # Strip unprintables; they can switch terminal modes when binary data
                # gets dumped, which is pretty annoying.
                $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text );
@@ -1227,8 +1226,8 @@ function wfErrorLog( $text, $file ) {
  * @todo document
  */
 function wfLogProfilingData() {
-       global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest;
-       global $wgProfileLimit, $wgUser;
+       global $wgRequestTime, $wgDebugLogFile, $wgDebugLogGroups, $wgDebugRawPage;
+       global $wgProfileLimit, $wgUser, $wgRequest;
 
        StatCounter::singleton()->flush();
 
@@ -1249,7 +1248,17 @@ function wfLogProfilingData() {
        $profiler->logData();
 
        // Check whether this should be logged in the debug file.
-       if ( $wgDebugLogFile == '' || ( !$wgDebugRawPage && wfIsDebugRawPage() ) ) {
+       if ( isset( $wgDebugLogGroups['profileoutput'] )
+               && $wgDebugLogGroups['profileoutput'] === false
+       ) {
+               // Explicitely disabled
+               return;
+       }
+       if ( !isset( $wgDebugLogGroups['profileoutput'] ) && $wgDebugLogFile == '' ) {
+               // Logging not enabled; no point going further
+               return;
+       }
+       if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
                return;
        }
 
@@ -1284,7 +1293,7 @@ function wfLogProfilingData() {
                gmdate( 'YmdHis' ), $elapsed,
                urldecode( $requestUrl . $forward ) );
 
-       wfErrorLog( $log . $profiler->getOutput(), $wgDebugLogFile );
+       wfDebugLog( 'profileoutput', $log . $profiler->getOutput() );
 }
 
 /**
@@ -1808,19 +1817,23 @@ function wfHostname() {
 }
 
 /**
- * Returns a HTML comment with the elapsed time since request.
- * This method has no side effects.
+ * Returns a script tag that stores the amount of time it took MediaWiki to
+ * handle the request in milliseconds as 'wgBackendResponseTime'.
+ *
+ * If $wgShowHostnames is true, the script will also set 'wgHostname' to the
+ * hostname of the server handling the request.
  *
  * @return string
  */
 function wfReportTime() {
        global $wgRequestTime, $wgShowHostnames;
 
-       $elapsed = microtime( true ) - $wgRequestTime;
-
-       return $wgShowHostnames
-               ? sprintf( '<!-- Served by %s in %01.3f secs. -->', wfHostname(), $elapsed )
-               : sprintf( '<!-- Served in %01.3f secs. -->', $elapsed );
+       $responseTime = round( ( microtime( true ) - $wgRequestTime ) * 1000 );
+       $reportVars = array( 'wgBackendResponseTime' => $responseTime );
+       if ( $wgShowHostnames ) {
+               $reportVars[ 'wgHostname' ] = wfHostname();
+       }
+       return Skin::makeVariablesScript( $reportVars );
 }
 
 /**