-/**
- * Stores objects in the main database of the wiki
- *
- * @ingroup Cache
- */
-class MediaWikiBagOStuff extends SqlBagOStuff {
- var $tableInitialised = false;
- var $lb, $db;
-
- function _getDB(){
- global $wgDBtype;
- if ( !isset( $this->db ) ) {
- /* We must keep a separate connection to MySQL in order to avoid deadlocks
- * However, SQLite has an opposite behaviour.
- * @todo Investigate behaviour for other databases
- */
- if ( $wgDBtype == 'sqlite' ) {
- $this->db = wfGetDB( DB_MASTER );
- } else {
- $this->lb = wfGetLBFactory()->newMainLB();
- $this->db = $this->lb->getConnection( DB_MASTER );
- $this->db->clearFlag( DBO_TRX );
- }
- }
- return $this->db;
- }
- function _begin() {
- $this->_getDB()->begin();
- }
- function _commit() {
- $this->_getDB()->commit();
- }
- function _doquery($sql) {
- return $this->_getDB()->query( $sql, __METHOD__ );
- }
- function _doinsert($t, $v) {
- return $this->_getDB()->insert($t, $v, __METHOD__, array( 'IGNORE' ) );
- }
- function _fetchobject($result) {
- return $this->_getDB()->fetchObject($result);
- }
- function _freeresult($result) {
- return $this->_getDB()->freeResult($result);
- }
- function _dberror($result) {
- return $this->_getDB()->lastError();
- }
- function _maxdatetime() {
- if ( time() > 0x7fffffff ) {
- return $this->_fromunixtime( 1<<62 );
- } else {
- return $this->_fromunixtime( 0x7fffffff );
- }
- }
- function _fromunixtime($ts) {
- return $this->_getDB()->timestamp($ts);
- }
- /***
- * Note -- this should *not* check wfReadOnly().
- * Read-only mode has been repurposed from the original
- * "nothing must write to the database" to "users should not
- * be able to edit or alter anything user-visible".
- *
- * Backend bits like the object cache should continue
- * to work in this mode, otherwise things will blow up
- * like the message cache failing to save its state,
- * causing long delays (bug 11533).