Made SqlDataUpdate use lazy DB connections
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 12 Jan 2015 21:39:24 +0000 (13:39 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 14 Jan 2015 02:40:32 +0000 (02:40 +0000)
Change-Id: Ic041f620f27e1e8012586542ac6dc60657461d04

includes/deferred/LinksUpdate.php
includes/deferred/SqlDataUpdate.php

index 822c964..9c377df 100644 (file)
@@ -58,12 +58,6 @@ class LinksUpdate extends SqlDataUpdate {
        /** @var array Map of arbitrary name to value */
        public $mProperties;
 
-       /** @var DatabaseBase Database connection reference */
-       public $mDb;
-
-       /** @var array SELECT options to be used */
-       public $mOptions;
-
        /** @var bool Whether to queue jobs for recursive updates */
        public $mRecursive;
 
index 7ec61ea..5823b2e 100644 (file)
@@ -31,7 +31,7 @@
  *       the beginTransaction() and commitTransaction() methods.
  */
 abstract class SqlDataUpdate extends DataUpdate {
-       /** @var DatabaseBase Database connection reference */
+       /** @var IDatabase Database connection reference */
        protected $mDb;
 
        /** @var array SELECT options to be used (array) */
@@ -53,9 +53,7 @@ abstract class SqlDataUpdate extends DataUpdate {
        public function __construct( $withTransaction = true ) {
                parent::__construct();
 
-               // @todo Get connection only when it's needed? Make sure that doesn't
-               // break anything, especially transactions!
-               $this->mDb = wfGetDB( DB_MASTER );
+               $this->mDb = wfGetLB()->getLazyConnectionRef( DB_MASTER );
 
                $this->mWithTransaction = $withTransaction;
                $this->mHasTransaction = false;