rdbms: move assertOpen() call near the top of Database::query
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Apr 2018 20:49:55 +0000 (13:49 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 5 Apr 2018 20:50:50 +0000 (13:50 -0700)
This should be done before bothering with begin() calls or setting
the value of fields like "trxDoneWrites" or "lastWriteTime".

Change-Id: Ieace2870f5496fcf230c5c8381baca4b8038db1d

includes/libs/rdbms/database/Database.php

index b395711..d7336c1 100644 (file)
@@ -1061,6 +1061,9 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
                $this->assertTransactionStatus( $sql, $fname );
 
+               # Avoid fatals if close() was called
+               $this->assertOpen();
+
                $priorWritesPending = $this->writesOrCallbacksPending();
                $this->lastQuery = $sql;
 
@@ -1111,9 +1114,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        $this->queryLogger->debug( "{$this->dbName} {$commentedSql}" );
                }
 
-               # Avoid fatals if close() was called
-               $this->assertOpen();
-
                # Send the query to the server and fetch any corresponding errors
                $ret = $this->doProfiledQuery( $sql, $commentedSql, $isNonTempWrite, $fname );
                $lastError = $this->lastError();