Move wfIncrStats() near other debugging functions
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 15 Feb 2012 16:17:02 +0000 (16:17 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 15 Feb 2012 16:17:02 +0000 (16:17 +0000)
includes/GlobalFunctions.php

index 7bddf83..5dbcbb1 100644 (file)
@@ -1200,6 +1200,57 @@ function wfLogProfilingData() {
        wfErrorLog( $log . $profiler->getOutput(), $wgDebugLogFile );
 }
 
+/**
+ * Increment a statistics counter
+ *
+ * @param $key String
+ * @param $count Int
+ */
+function wfIncrStats( $key, $count = 1 ) {
+       global $wgStatsMethod;
+
+       $count = intval( $count );
+
+       if( $wgStatsMethod == 'udp' ) {
+               global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
+               static $socket;
+
+               $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
+
+               if ( !$socket ) {
+                       $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
+                       $statline = "stats/{$id} - 1 1 1 1 1 -total\n";
+                       socket_sendto(
+                               $socket,
+                               $statline,
+                               strlen( $statline ),
+                               0,
+                               $wgUDPProfilerHost,
+                               $wgUDPProfilerPort
+                       );
+               }
+               $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
+               wfSuppressWarnings();
+               socket_sendto(
+                       $socket,
+                       $statline,
+                       strlen( $statline ),
+                       0,
+                       $wgUDPProfilerHost,
+                       $wgUDPProfilerPort
+               );
+               wfRestoreWarnings();
+       } elseif( $wgStatsMethod == 'cache' ) {
+               global $wgMemc;
+               $key = wfMemcKey( 'stats', $key );
+               if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
+                       $wgMemc->add( $key, $count );
+               }
+       } else {
+               // Disabled
+       }
+}
+
 /**
  * Check if the wiki read-only lock file is present. This can be used to lock
  * off editing functions, but doesn't guarantee that the database will not be
@@ -2562,57 +2613,6 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
        return $ok;
 }
 
-/**
- * Increment a statistics counter
- *
- * @param $key String
- * @param $count Int
- */
-function wfIncrStats( $key, $count = 1 ) {
-       global $wgStatsMethod;
-
-       $count = intval( $count );
-
-       if( $wgStatsMethod == 'udp' ) {
-               global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID;
-               static $socket;
-
-               $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname;
-
-               if ( !$socket ) {
-                       $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
-                       $statline = "stats/{$id} - 1 1 1 1 1 -total\n";
-                       socket_sendto(
-                               $socket,
-                               $statline,
-                               strlen( $statline ),
-                               0,
-                               $wgUDPProfilerHost,
-                               $wgUDPProfilerPort
-                       );
-               }
-               $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n";
-               wfSuppressWarnings();
-               socket_sendto(
-                       $socket,
-                       $statline,
-                       strlen( $statline ),
-                       0,
-                       $wgUDPProfilerHost,
-                       $wgUDPProfilerPort
-               );
-               wfRestoreWarnings();
-       } elseif( $wgStatsMethod == 'cache' ) {
-               global $wgMemc;
-               $key = wfMemcKey( 'stats', $key );
-               if ( is_null( $wgMemc->incr( $key, $count ) ) ) {
-                       $wgMemc->add( $key, $count );
-               }
-       } else {
-               // Disabled
-       }
-}
-
 /**
  * @param $nr Mixed: the number to format
  * @param $acc Integer: the number of digits after the decimal point, default 2