Merge "CologneBlue rewrite: fix talkLink() to use generic nav links"
[lhc/web/wiklou.git] / includes / filebackend / filejournal / DBFileJournal.php
index 8fa4c6f..34f3e53 100644 (file)
@@ -27,6 +27,9 @@
  * @since 1.20
  */
 class DBFileJournal extends FileJournal {
+       /** @var DatabaseBase */
+       protected $dbw;
+
        protected $wiki = false; // string; wiki DB name
 
        /**
@@ -71,9 +74,7 @@ class DBFileJournal extends FileJournal {
                }
 
                try {
-                       $dbw->begin();
                        $dbw->insert( 'filejournal', $data, __METHOD__ );
-                       $dbw->commit();
                } catch ( DBError $e ) {
                        $status->fatal( 'filejournal-fail-dbquery', $this->backend );
                        return $status;
@@ -82,6 +83,19 @@ class DBFileJournal extends FileJournal {
                return $status;
        }
 
+       /**
+        * @see FileJournal::doGetCurrentPosition()
+        * @return integer|false
+        */
+       protected function doGetCurrentPosition() {
+               $dbw = $this->getMasterDB();
+
+               return $dbw->selectField( 'filejournal', 'MAX(fj_id)',
+                       array( 'fj_backend' => $this->backend ),
+                       __METHOD__
+               );
+       }
+
        /**
         * @see FileJournal::doGetChangeEntries()
         * @return Array
@@ -125,12 +139,10 @@ class DBFileJournal extends FileJournal {
                $dbw = $this->getMasterDB();
                $dbCutoff = $dbw->timestamp( time() - 86400 * $this->ttlDays );
 
-               $dbw->begin();
                $dbw->delete( 'filejournal',
                        array( 'fj_timestamp < ' . $dbw->addQuotes( $dbCutoff ) ),
                        __METHOD__
                );
-               $dbw->commit();
 
                return $status;
        }
@@ -142,7 +154,12 @@ class DBFileJournal extends FileJournal {
         * @throws DBError
         */
        protected function getMasterDB() {
-               $lb = wfGetLBFactory()->newMainLB();
-               return $lb->getConnection( DB_MASTER, array(), $this->wiki );
+               if ( !$this->dbw ) {
+                       // Get a separate connection in autocommit mode
+                       $lb = wfGetLBFactory()->newMainLB();
+                       $this->dbw = $lb->getConnection( DB_MASTER, array(), $this->wiki );
+                       $this->dbw->clearFlag( DBO_TRX );
+               }
+               return $this->dbw;
        }
 }