Merge "Remove deprecated ApiAction logging code from ApiMain.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Jun 2019 20:47:01 +0000 (20:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Jun 2019 20:47:01 +0000 (20:47 +0000)
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/libs/rdbms/loadbalancer/ILoadBalancer.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/libs/rdbms/loadmonitor/LoadMonitor.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderContext.php
includes/specials/SpecialNewpages.php
resources/src/mediawiki.special.userlogin.signup.styles/signup.css

index 5451476..bc8883c 100644 (file)
@@ -4245,6 +4245,16 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        public function getLag() {
+               if ( $this->getLBInfo( 'master' ) ) {
+                       return 0; // this is the master
+               } elseif ( $this->getLBInfo( 'is static' ) ) {
+                       return 0; // static dataset
+               }
+
+               return $this->doGetLag();
+       }
+
+       protected function doGetLag() {
                return 0;
        }
 
index b5f83da..ef28f33 100644 (file)
@@ -744,7 +744,7 @@ abstract class DatabaseMysqlBase extends Database {
                return strlen( $name ) && $name[0] == '`' && substr( $name, -1, 1 ) == '`';
        }
 
-       public function getLag() {
+       protected function doGetLag() {
                if ( $this->getLagDetectionMethod() === 'pt-heartbeat' ) {
                        return $this->getLagFromPtHeartbeat();
                } else {
index a2202b6..22281c1 100644 (file)
@@ -604,22 +604,6 @@ interface ILoadBalancer {
         */
        public function getLagTimes( $domain = false );
 
-       /**
-        * Get the lag in seconds for a given connection, or zero if this load
-        * balancer does not have replication enabled.
-        *
-        * This should be used in preference to Database::getLag() in cases where
-        * replication may not be in use, since there is no way to determine if
-        * replication is in use at the connection level without running
-        * potentially restricted queries such as SHOW SLAVE STATUS. Using this
-        * function instead of Database::getLag() avoids a fatal error in this
-        * case on many installations.
-        *
-        * @param IDatabase $conn
-        * @return int|bool Returns false on error
-        */
-       public function safeGetLag( IDatabase $conn );
-
        /**
         * Wait for a replica DB to reach a specified master position
         *
index 62f4582..f0e4b4f 100644 (file)
@@ -1959,6 +1959,21 @@ class LoadBalancer implements ILoadBalancer {
                return $this->getLoadMonitor()->getLagTimes( $indexesWithLag, $domain ) + $knownLagTimes;
        }
 
+       /**
+        * Get the lag in seconds for a given connection, or zero if this load
+        * balancer does not have replication enabled.
+        *
+        * This should be used in preference to Database::getLag() in cases where
+        * replication may not be in use, since there is no way to determine if
+        * replication is in use at the connection level without running
+        * potentially restricted queries such as SHOW SLAVE STATUS. Using this
+        * function instead of Database::getLag() avoids a fatal error in this
+        * case on many installations.
+        *
+        * @param IDatabase $conn
+        * @return int|bool Returns false on error
+        * @deprecated Since 1.34 Use IDatabase::getLag() instead
+        */
        public function safeGetLag( IDatabase $conn ) {
                if ( $this->getServerCount() <= 1 ) {
                        return 0;
@@ -1981,7 +1996,8 @@ class LoadBalancer implements ILoadBalancer {
                        if ( $masterConn ) {
                                $pos = $masterConn->getMasterPos();
                        } else {
-                               $masterConn = $this->getConnection( $index, [], self::DOMAIN_ANY, self::CONN_SILENCE_ERRORS );
+                               $flags = self::CONN_SILENCE_ERRORS;
+                               $masterConn = $this->getConnection( $index, [], self::DOMAIN_ANY, $flags );
                                if ( !$masterConn ) {
                                        throw new DBReplicationWaitError(
                                                null,
index aa1e9b2..1666c27 100644 (file)
@@ -181,25 +181,21 @@ class LoadMonitor implements ILoadMonitor {
                                continue;
                        }
 
-                       if ( $conn->getLBInfo( 'is static' ) ) {
-                               $lagTimes[$i] = 0;
-                       } else {
-                               $lagTimes[$i] = $conn->getLag();
-                               if ( $lagTimes[$i] === false ) {
-                                       $this->replLogger->error(
-                                               __METHOD__ . ": host {db_server} is not replicating?",
-                                               [ 'db_server' => $host ]
-                                       );
-                               } elseif ( $lagTimes[$i] > $this->lagWarnThreshold ) {
-                                       $this->replLogger->warning(
-                                               "Server {host} has {lag} seconds of lag (>= {maxlag})",
-                                               [
-                                                       'host' => $host,
-                                                       'lag' => $lagTimes[$i],
-                                                       'maxlag' => $this->lagWarnThreshold
-                                               ]
-                                       );
-                               }
+                       $lagTimes[$i] = $conn->getLag();
+                       if ( $lagTimes[$i] === false ) {
+                               $this->replLogger->error(
+                                       __METHOD__ . ": host {db_server} is not replicating?",
+                                       [ 'db_server' => $host ]
+                               );
+                       } elseif ( $lagTimes[$i] > $this->lagWarnThreshold ) {
+                               $this->replLogger->warning(
+                                       "Server {host} has {lag} seconds of lag (>= {maxlag})",
+                                       [
+                                               'host' => $host,
+                                               'lag' => $lagTimes[$i],
+                                               'maxlag' => $this->lagWarnThreshold
+                                       ]
+                               );
                        }
 
                        if ( $close ) {
index 2ae6d74..8ce4ab9 100644 (file)
@@ -1721,10 +1721,10 @@ MESSAGE;
                // match the defaults assumed by ResourceLoaderContext.
                // Note: This relies on the defaults either being insignificant or forever constant,
                // as otherwise cached urls could change in meaning when the defaults change.
-               if ( $lang !== 'qqx' ) {
+               if ( $lang !== ResourceLoaderContext::DEFAULT_LANG ) {
                        $query['lang'] = $lang;
                }
-               if ( $skin !== 'fallback' ) {
+               if ( $skin !== ResourceLoaderContext::DEFAULT_SKIN ) {
                        $query['skin'] = $skin;
                }
                if ( $debug === true ) {
index f57f13b..95a81e6 100644 (file)
@@ -30,6 +30,9 @@ use MediaWiki\MediaWikiServices;
  * of a specific loader request.
  */
 class ResourceLoaderContext implements MessageLocalizer {
+       const DEFAULT_LANG = 'qqx';
+       const DEFAULT_SKIN = 'fallback';
+
        protected $resourceLoader;
        protected $request;
        protected $logger;
@@ -88,7 +91,7 @@ class ResourceLoaderContext implements MessageLocalizer {
                        // The 'skin' parameter is required. (Not yet enforced.)
                        // For requests without a known skin specified,
                        // use MediaWiki's 'fallback' skin for skin-specific decisions.
-                       $this->skin = 'fallback';
+                       $this->skin = self::DEFAULT_SKIN;
                }
        }
 
@@ -178,7 +181,7 @@ class ResourceLoaderContext implements MessageLocalizer {
                        if ( !Language::isValidBuiltInCode( $lang ) ) {
                                // The 'lang' parameter is required. (Not yet enforced.)
                                // If omitted, localise with the dummy language code.
-                               $lang = 'qqx';
+                               $lang = self::DEFAULT_LANG;
                        }
                        $this->language = $lang;
                }
index 1b8ba85..04db704 100644 (file)
@@ -160,6 +160,8 @@ class SpecialNewpages extends IncludableSpecialPage {
                                $navigation = $pager->getNavigationBar();
                        }
                        $out->addHTML( $navigation . $pager->getBody() . $navigation );
+                       // Add styles for change tags
+                       $out->addModuleStyles( 'mediawiki.interface.helpers.styles' );
                } else {
                        $out->addWikiMsg( 'specialpage-empty' );
                }
index d8b773c..1e9400a 100644 (file)
@@ -43,9 +43,9 @@
 
 /*
  * Special font for numbers in benefits, same as Vector's `@content-heading-font-family`.
- * Needs an ID so that it's more specific than Vector's div#content h3.
+ * Needs to be more specific than Vector's `.mw-body-content h3`.
  */
-#bodyContent .mw-number-text h3 {
+.mw-body-content .mw-number-text h3 {
        color: #222;
        margin: 0;
        padding: 0;