return $this->__call( __FUNCTION__, func_get_args() );
}
+ public function assertNoOpenTransactions() {
+ return $this->__call( __FUNCTION__, func_get_args() );
+ }
+
public function tablePrefix( $prefix = null ) {
return $this->__call( __FUNCTION__, func_get_args() );
}
}
}
+ public function assertNoOpenTransactions() {
+ if ( $this->explicitTrxActive() ) {
+ throw new DBTransactionError(
+ $this,
+ "Explicit transaction still active. A caller may have caught an error. "
+ . "Open transactions: " . $this->flatAtomicSectionList()
+ );
+ }
+ }
+
/**
* Determine whether or not it is safe to retry queries after a database
* connection is lost
*/
public function explicitTrxActive();
+ /**
+ * Assert that all explicit transactions or atomic sections have been closed.
+ * @throws DBTransactionError
+ * @since 1.32
+ */
+ public function assertNoOpenTransactions();
+
/**
* Get/set the table prefix.
* @param string|null $prefix The table prefix to set, or omitted to leave it unchanged.
// If atomic sections or explicit transactions are still open, some caller must have
// caught an exception but failed to properly rollback any changes. Detect that and
// throw and error (causing rollback).
- if ( $conn->explicitTrxActive() ) {
- throw new DBTransactionError(
- $conn,
- "Explicit transaction still active. A caller may have caught an error."
- );
- }
+ $conn->assertNoOpenTransactions();
// Assert that the time to replicate the transaction will be sane.
// If this fails, then all DB transactions will be rollback back together.
$time = $conn->pendingWriteQueryDuration( $conn::ESTIMATE_DB_APPLY );