* @ingroup Cache
*/
class SqlBagOStuff extends BagOStuff {
+ /** @var LoadBalancer */
+ protected $lb;
+
protected $serverInfos;
/** @var array */
$db = DatabaseBase::factory( $type, $info );
$db->clearFlag( DBO_TRX );
} else {
- // We must keep a separate connection to MySQL in order to avoid deadlocks
- // However, SQLite has an opposite behavior.
- // @todo get this trick to work on PostgreSQL too
+ /*
+ * We must keep a separate connection to MySQL in order to avoid deadlocks
+ * However, SQLite has an opposite behavior. And PostgreSQL needs to know
+ * if we are in transaction or no
+ */
if ( wfGetDB( DB_MASTER )->getType() == 'mysql' ) {
- $lb = wfGetLBFactory()->newMainLB();
- $db = $lb->getConnection( DB_MASTER );
+ $this->lb = wfGetLBFactory()->newMainLB();
+ $db = $this->lb->getConnection( DB_MASTER );
$db->clearFlag( DBO_TRX ); // auto-commit mode
} else {
$db = wfGetDB( DB_MASTER );
// We do not want to flush the TRX as that can break callers.
$db->trxLevel() ? array( 'LOCK IN SHARE MODE' ) : array()
);
+ if ( $res === false ) {
+ continue;
+ }
foreach ( $res as $row ) {
$row->serverIndex = $serverIndex;
$row->tableName = $tableName;
}
/**
+ * @param DatabaseBase $db
* @param string $exptime
* @return bool
*/
$conds,
__METHOD__,
array( 'LIMIT' => 100, 'ORDER BY' => 'exptime' ) );
- if ( !$rows->numRows() ) {
+ if ( $rows === false || !$rows->numRows() ) {
break;
}
$keys = array();