merged master
[lhc/web/wiklou.git] / includes / SqlDataUpdate.php
index aeb9ba4..6abbffb 100644 (file)
@@ -51,8 +51,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;
        }
 
@@ -63,6 +61,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'  );
@@ -83,7 +83,7 @@ abstract class SqlDataUpdate extends DataUpdate {
         * Abort the database transaction started via beginTransaction (if any).
         */
        public function abortTransaction() {
-               if ( $this->mHasTransaction ) {
+               if ( $this->mHasTransaction ) { //XXX: actually... maybe always?
                        $this->mDb->rollback( get_class( $this ) . '::abortTransaction' );
                }
        }