Merge "Update formatting of file backend classes"
[lhc/web/wiklou.git] / includes / filebackend / filejournal / DBFileJournal.php
index 44c6567..42f4f1a 100644 (file)
@@ -56,6 +56,7 @@ class DBFileJournal extends FileJournal {
                        $dbw = $this->getMasterDB();
                } catch ( DBError $e ) {
                        $status->fatal( 'filejournal-fail-dbconnect', $this->backend );
+
                        return $status;
                }
 
@@ -65,11 +66,11 @@ class DBFileJournal extends FileJournal {
                foreach ( $entries as $entry ) {
                        $data[] = array(
                                'fj_batch_uuid' => $batchId,
-                               'fj_backend'    => $this->backend,
-                               'fj_op'         => $entry['op'],
-                               'fj_path'       => $entry['path'],
-                               'fj_new_sha1'   => $entry['newSha1'],
-                               'fj_timestamp'  => $dbw->timestamp( $now )
+                               'fj_backend' => $this->backend,
+                               'fj_op' => $entry['op'],
+                               'fj_path' => $entry['path'],
+                               'fj_new_sha1' => $entry['newSha1'],
+                               'fj_timestamp' => $dbw->timestamp( $now )
                        );
                }
 
@@ -80,6 +81,7 @@ class DBFileJournal extends FileJournal {
                        }
                } catch ( DBError $e ) {
                        $status->fatal( 'filejournal-fail-dbquery', $this->backend );
+
                        return $status;
                }
 
@@ -99,6 +101,23 @@ class DBFileJournal extends FileJournal {
                );
        }
 
+       /**
+        * @see FileJournal::doGetPositionAtTime()
+        * @param $time integer|string timestamp
+        * @return integer|false
+        */
+       protected function doGetPositionAtTime( $time ) {
+               $dbw = $this->getMasterDB();
+
+               $encTimestamp = $dbw->addQuotes( $dbw->timestamp( $time ) );
+
+               return $dbw->selectField( 'filejournal', 'fj_id',
+                       array( 'fj_backend' => $this->backend, "fj_timestamp <= $encTimestamp" ),
+                       __METHOD__,
+                       array( 'ORDER BY' => 'fj_timestamp DESC' )
+               );
+       }
+
        /**
         * @see FileJournal::doGetChangeEntries()
         * @return Array
@@ -163,6 +182,7 @@ class DBFileJournal extends FileJournal {
                        $this->dbw = $lb->getConnection( DB_MASTER, array(), $this->wiki );
                        $this->dbw->clearFlag( DBO_TRX );
                }
+
                return $this->dbw;
        }
 }