From: daniel Date: Wed, 13 Jun 2012 10:30:55 +0000 (+0200) Subject: make SqlDataUpdate connect to database only when starting the transaction, not in... X-Git-Tag: 1.31.0-rc.0~22097^2^2~103 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=f08b275cae40c021552e256ffa74f2651169c969;p=lhc%2Fweb%2Fwiklou.git make SqlDataUpdate connect to database only when starting the transaction, not in the constructor --- 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' );