Merge "Adding wfLogWarning for production warnings."
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 004284e..7d54cb8 100644 (file)
@@ -1190,6 +1190,8 @@ function wfLogProfilingData() {
        global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest;
        global $wgProfileLimit, $wgUser;
 
+       StatCounter::singleton()->flush();
+
        $profiler = Profiler::instance();
 
        # Profiling must actually be enabled...
@@ -1253,51 +1255,7 @@ function wfLogProfilingData() {
  * @return void
  */
 function wfIncrStats( $key, $count = 1 ) {
-       global $wgStatsMethod;
-
-       $count = intval( $count );
-       if ( $count == 0 ) {
-               return;
-       }
-
-       if( $wgStatsMethod == 'udp' ) {
-               global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgAggregateStatsID;
-               static $socket;
-
-               $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : wfWikiID();
-
-               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
-       }
+       StatCounter::singleton()->incr( $key, $count );
 }
 
 /**
@@ -3350,7 +3308,7 @@ function wfCheckEntropy() {
  */
 function wfFixSessionID() {
        // If the cookie or session id is already set we already have a session and should abort
-       if ( isset( $_COOKIE[ session_name() ] ) || session_id() ) {
+       if ( isset( $_COOKIE[session_name()] ) || session_id() ) {
                return;
        }
 
@@ -3667,7 +3625,7 @@ function wfWaitForSlaves( $maxLag = false, $wiki = false ) {
        // bug 27975 - Don't try to wait for slaves if there are none
        // Prevents permission error when getting master position
        if ( $lb->getServerCount() > 1 ) {
-               $dbw = $lb->getConnection( DB_MASTER );
+               $dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
                $pos = $dbw->getMasterPos();
                $lb->waitForAll( $pos );
        }
@@ -3952,7 +3910,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
        # Handle redirects
        $redirectTitle = RepoGroup::singleton()->checkRedirect( Title::makeTitle( NS_FILE, $name ) );
        if( $redirectTitle ) {
-               $name = $redirectTitle->getDbKey();
+               $name = $redirectTitle->getDBkey();
        }
 
        # Run the extension hook