summaryrefslogtreecommitdiff
path: root/includes/filebackend/filejournal/DBFileJournal.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/filebackend/filejournal/DBFileJournal.php')
-rw-r--r--includes/filebackend/filejournal/DBFileJournal.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/includes/filebackend/filejournal/DBFileJournal.php b/includes/filebackend/filejournal/DBFileJournal.php
index f6268c25..73f29a95 100644
--- a/includes/filebackend/filejournal/DBFileJournal.php
+++ b/includes/filebackend/filejournal/DBFileJournal.php
@@ -75,6 +75,9 @@ class DBFileJournal extends FileJournal {
try {
$dbw->insert( 'filejournal', $data, __METHOD__ );
+ if ( mt_rand( 0, 99 ) == 0 ) {
+ $this->purgeOldLogs(); // occasionally delete old logs
+ }
} catch ( DBError $e ) {
$status->fatal( 'filejournal-fail-dbquery', $this->backend );
return $status;
@@ -84,6 +87,35 @@ class DBFileJournal extends FileJournal {
}
/**
+ * @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::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
* @throws DBError