* @return bool
*/
public function doneWrites() {
- return $this->mDoneWrites;
+ return (bool)$this->mDoneWrites;
+ }
+
+ /**
+ * Returns the last time the connection may have been used for write queries.
+ * Should return a timestamp if unsure.
+ *
+ * @return int|float UNIX timestamp or false
+ * @since 1.24
+ */
+ public function lastDoneWrites() {
+ return $this->mDoneWrites ?: false;
}
/**
global $wgUser, $wgDebugDBTransactions;
$this->mLastQuery = $sql;
- if ( !$this->mDoneWrites && $this->isWriteQuery( $sql ) ) {
+ if ( $this->isWriteQuery( $sql ) ) {
# Set a flag indicating that writes have been done
wfDebug( __METHOD__ . ': Writes done: ' . DatabaseBase::generalizeSQL( $sql ) . "\n" );
- $this->mDoneWrites = true;
+ $this->mDoneWrites = microtime( true );
}
# Add a comment for easy SHOW PROCESSLIST interpretation
# All newlines, tabs, etc replaced by single space
$sql = preg_replace( '/\s+/', ' ', $sql );
- # All numbers => N
+ # All numbers => N,
+ # except the ones surrounded by characters, e.g. l10n
$sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
- $sql = preg_replace( '/-?\d+/s', 'N', $sql );
+ $sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/s', 'N', $sql );
return $sql;
}