From f08b275cae40c021552e256ffa74f2651169c969 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 13 Jun 2012 12:30:55 +0200 Subject: [PATCH] make SqlDataUpdate connect to database only when starting the transaction, not in the constructor --- includes/SqlDataUpdate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/SqlDataUpdate.php b/includes/SqlDataUpdate.php index 6d36a439ed..a56a45473f 100644 --- a/includes/SqlDataUpdate.php +++ b/includes/SqlDataUpdate.php @@ -46,8 +46,6 @@ abstract class SqlDataUpdate extends DataUpdate { $this->mOptions = array( 'FOR UPDATE' ); } - // @todo: get connection only when it's needed? make sure that doesn't break anything, especially transactions! - $this->mDb = wfGetDB( DB_MASTER ); $this->mHasTransaction = false; } @@ -58,6 +56,8 @@ abstract class SqlDataUpdate extends DataUpdate { * checkes Database::trxLevel() and only opens a transaction if none is yet active. */ public function beginTransaction() { + $this->mDb = wfGetDB( DB_MASTER ); + // NOTE: nested transactions are not supported, only start a transaction if none is open if ( $this->mDb->trxLevel() === 0 ) { $this->mDb->begin( get_class( $this ) . '::beginTransaction' ); -- 2.20.1