Use getConnectionRef() in ForeignDBViaLBRepo
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 6 Oct 2016 00:10:43 +0000 (17:10 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 6 Oct 2016 00:10:43 +0000 (17:10 -0700)
This assures that reuseConnection() will be called.

Change-Id: I6b9eb695d08045433ebb3204c0f72bcf63f21568

includes/filerepo/ForeignDBViaLBRepo.php

index 55df1af..129d55a 100644 (file)
@@ -59,23 +59,22 @@ class ForeignDBViaLBRepo extends LocalRepo {
         * @return IDatabase
         */
        function getMasterDB() {
-               return wfGetDB( DB_MASTER, [], $this->wiki );
+               return wfGetLB( $this->wiki )->getConnectionRef( DB_MASTER, [], $this->wiki );
        }
 
        /**
         * @return IDatabase
         */
        function getSlaveDB() {
-               return wfGetDB( DB_REPLICA, [], $this->wiki );
+               return wfGetLB( $this->wiki )->getConnectionRef( DB_REPLICA, [], $this->wiki );
        }
 
        /**
         * @return Closure
         */
        protected function getDBFactory() {
-               $wiki = $this->wiki;
-               return function( $index ) use ( $wiki ) {
-                       return wfGetDB( $index, [], $wiki );
+               return function( $index ) {
+                       return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki );
                };
        }