rdbms: clean up use of ATTACH queries in DatabaseSqlite
[lhc/web/wiklou.git] / includes / libs / rdbms / database / Database.php
index 084500a..6aa3f6f 100644 (file)
@@ -1487,6 +1487,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                $this->trxAtomicCounter = 0;
                $this->trxIdleCallbacks = []; // T67263; transaction already lost
                $this->trxPreCommitCallbacks = []; // T67263; transaction already lost
+               // Clear additional subclass fields
+               $this->doHandleSessionLossPreconnect();
                // @note: leave trxRecurringCallbacks in place
                if ( $this->trxDoneWrites ) {
                        $this->trxProfiler->transactionWritingOut(
@@ -1499,6 +1501,13 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                }
        }
 
+       /**
+        * Reset any additional subclass trx* and session* fields
+        */
+       protected function doHandleSessionLossPreconnect() {
+               // no-op
+       }
+
        /**
         * Clean things up after session (and thus transaction) loss after reconnect
         */
@@ -3522,7 +3531,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        if ( in_array( $entry[2], $sectionIds, true ) ) {
                                $callback = $entry[0];
                                $this->trxEndCallbacks[$key][0] = function () use ( $callback ) {
-                                       // @phan-suppress-next-line PhanInfiniteRecursion No recursion at all here, phan is confused
+                                       // @phan-suppress-next-line PhanInfiniteRecursion, PhanUndeclaredInvokeInCallable
                                        return $callback( self::TRIGGER_ROLLBACK, $this );
                                };
                                // This "on resolution" callback no longer belongs to a section.
@@ -3647,6 +3656,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                                try {
                                        ++$count;
                                        list( $phpCallback ) = $callback;
+                                       // @phan-suppress-next-line PhanUndeclaredInvokeInCallable
                                        $phpCallback( $this );
                                } catch ( Exception $ex ) {
                                        ( $this->errorLogger )( $ex );
@@ -3682,6 +3692,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        foreach ( $callbacks as $entry ) {
                                if ( $sectionIds === null || in_array( $entry[2], $sectionIds, true ) ) {
                                        try {
+                                               // @phan-suppress-next-line PhanUndeclaredInvokeInCallable
                                                $entry[0]( $trigger, $this );
                                        } catch ( Exception $ex ) {
                                                ( $this->errorLogger )( $ex );