Convert LoadBalancer::getConnection() callers to LoadBalancer::getConnectionRef()
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 21 Jul 2019 08:02:49 +0000 (01:02 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 21 Jul 2019 08:02:49 +0000 (01:02 -0700)
Change-Id: Ie1ae322202105ce093779e6d0b00f335c71be31f

includes/Revision/RevisionStore.php
includes/SiteStatsInit.php
includes/Storage/SqlBlobStore.php
includes/objectcache/SqlBagOStuff.php

index 8a4b6dc..fe5b5b9 100644 (file)
@@ -284,7 +284,7 @@ class RevisionStore
         */
        private function getDBConnection( $mode, $groups = [] ) {
                $lb = $this->getDBLoadBalancer();
-               return $lb->getConnection( $mode, $groups, $this->dbDomain );
+               return $lb->getConnectionRef( $mode, $groups, $this->dbDomain );
        }
 
        /**
index 932e1c3..2252f8f 100644 (file)
@@ -195,8 +195,8 @@ class SiteStatsInit {
         * @return IDatabase
         */
        private static function getDB( $index, $groups = [] ) {
-               $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
-
-               return $lb->getConnection( $index, $groups );
+               return MediaWikiServices::getInstance()
+                       ->getDBLoadBalancer()
+                       ->getConnectionRef( $index, $groups );
        }
 }
index 5260754..d1b688b 100644 (file)
@@ -207,7 +207,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
         */
        private function getDBConnection( $index ) {
                $lb = $this->getDBLoadBalancer();
-               return $lb->getConnection( $index, [], $this->dbDomain );
+               return $lb->getConnectionRef( $index, [], $this->dbDomain );
        }
 
        /**
index 9226875..6cc63bf 100644 (file)
@@ -27,6 +27,7 @@ use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\DBError;
 use Wikimedia\Rdbms\DBQueryError;
 use Wikimedia\Rdbms\DBConnectionError;
+use Wikimedia\Rdbms\IMaintainableDatabase;
 use Wikimedia\Rdbms\LoadBalancer;
 use Wikimedia\ScopedCallback;
 use Wikimedia\WaitConditionLoop;
@@ -165,7 +166,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
         * Get a connection to the specified database
         *
         * @param int $serverIndex
-        * @return Database
+        * @return IMaintainableDatabase
         * @throws MWException
         */
        protected function getDB( $serverIndex ) {
@@ -199,11 +200,11 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
                        $index = $this->replicaOnly ? DB_REPLICA : DB_MASTER;
                        if ( $lb->getServerType( $lb->getWriterIndex() ) !== 'sqlite' ) {
                                // Keep a separate connection to avoid contention and deadlocks
-                               $db = $lb->getConnection( $index, [], false, $lb::CONN_TRX_AUTOCOMMIT );
+                               $db = $lb->getConnectionRef( $index, [], false, $lb::CONN_TRX_AUTOCOMMIT );
                        } else {
                                // However, SQLite has the opposite behavior due to DB-level locking.
                                // Stock sqlite MediaWiki installs use a separate sqlite cache DB instead.
-                               $db = $lb->getConnection( $index );
+                               $db = $lb->getConnectionRef( $index );
                        }
                }