Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183887
Change subject: Made SqlDataUpdate serializable and use lazy connection while
at it
......................................................................
Made SqlDataUpdate serializable and use lazy connection while at it
Change-Id: Iffa9ab3408e53f2f40ec012037c0cf182031df7e
---
M includes/deferred/LinksUpdate.php
M includes/deferred/SqlDataUpdate.php
2 files changed, 13 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/87/183887/1
diff --git a/includes/deferred/LinksUpdate.php
b/includes/deferred/LinksUpdate.php
index 822c964..9c377df 100644
--- a/includes/deferred/LinksUpdate.php
+++ b/includes/deferred/LinksUpdate.php
@@ -58,12 +58,6 @@
/** @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;
diff --git a/includes/deferred/SqlDataUpdate.php
b/includes/deferred/SqlDataUpdate.php
index 7ec61ea..4f239d1 100644
--- a/includes/deferred/SqlDataUpdate.php
+++ b/includes/deferred/SqlDataUpdate.php
@@ -31,7 +31,7 @@
* the beginTransaction() and commitTransaction() methods.
*/
abstract class SqlDataUpdate extends DataUpdate {
- /** @var DatabaseBase Database connection reference */
+ /** @var IDatabase */
protected $mDb;
/** @var array SELECT options to be used (array) */
@@ -53,9 +53,7 @@
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;
@@ -148,4 +146,15 @@
), __METHOD__
);
}
+
+ public function __sleep() {
+ return array_diff(
+ array_keys( get_object_vars( $this ) ),
+ array( 'mDb' ) // not serializable
+ );
+ }
+
+ public function __wakeup() {
+ $this->mDb = wfGetLB()->getLazyConnectionRef( DB_MASTER );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/183887
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffa9ab3408e53f2f40ec012037c0cf182031df7e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits