Merge "Read full memcached response before manipulating data"
[lhc/web/wiklou.git] / includes / filebackend / filejournal / FileJournal.php
index 234788b..b0f39c3 100644 (file)
@@ -43,7 +43,7 @@ abstract class FileJournal {
         * Construct a new instance from configuration.
         * $config includes:
         *     'ttlDays' : days to keep log entries around (false means "forever")
-        * 
+        *
         * @param $config Array
         */
        protected function __construct( array $config ) {
@@ -70,7 +70,7 @@ abstract class FileJournal {
 
        /**
         * Get a statistically unique ID string
-        * 
+        *
         * @return string <9 char TS_MW timestamp in base 36><22 random base 36 chars>
         */
        final public function getTimestampedUUID() {
@@ -85,11 +85,11 @@ abstract class FileJournal {
        /**
         * Log changes made by a batch file operation.
         * $entries is an array of log entries, each of which contains:
-        *     op      : Basic operation name (create, store, copy, delete)
+        *     op      : Basic operation name (create, update, delete)
         *     path    : The storage path of the file
         *     newSha1 : The final base 36 SHA-1 of the file
         * Note that 'false' should be used as the SHA-1 for non-existing files.
-        * 
+        *
         * @param $entries Array List of file operations (each an array of parameters)
         * @param $batchId string UUID string that identifies the operation batch
         * @return Status
@@ -103,13 +103,45 @@ abstract class FileJournal {
 
        /**
         * @see FileJournal::logChangeBatch()
-        * 
+        *
         * @param $entries Array List of file operations (each an array of parameters)
         * @param $batchId string UUID string that identifies the operation batch
         * @return Status
         */
        abstract protected function doLogChangeBatch( array $entries, $batchId );
 
+       /**
+        * Get the position ID of the latest journal entry
+        *
+        * @return integer|false
+        */
+       final public function getCurrentPosition() {
+               return $this->doGetCurrentPosition();
+       }
+
+       /**
+        * @see FileJournal::getCurrentPosition()
+        * @return integer|false
+        */
+       abstract protected function doGetCurrentPosition();
+
+       /**
+        * Get the position ID of the latest journal entry at some point in time
+        *
+        * @param $time integer|string timestamp
+        * @return integer|false
+        */
+       final public function getPositionAtTime( $time ) {
+               return $this->doGetPositionAtTime( $time );
+       }
+
+       /**
+        * @see FileJournal::getPositionAtTime()
+        * @param $time integer|string timestamp
+        * @return integer|false
+        */
+       abstract protected function doGetPositionAtTime( $time );
+
        /**
         * Get an array of file change log entries.
         * A starting change ID and/or limit can be specified.
@@ -118,9 +150,9 @@ abstract class FileJournal {
         *     id         : unique, monotonic, ID for this change
         *     batch_uuid : UUID for an operation batch
         *     backend    : the backend name
-        *     op         : primitive operation (create,update,delete)
+        *     op         : primitive operation (create,update,delete,null)
         *     path       : affected storage path
-        *     path_sha1  : base 36 sha1 of the affected storage path
+        *     new_sha1   : base 36 sha1 of the new file had the operation succeeded
         *     timestamp  : TS_MW timestamp of the batch change
 
         * Also, $next is updated to the ID of the next entry.
@@ -169,7 +201,7 @@ abstract class FileJournal {
  */
 class NullFileJournal extends FileJournal {
        /**
-        * @see FileJournal::logChangeBatch()
+        * @see FileJournal::doLogChangeBatch()
         * @param $entries array
         * @param $batchId string
         * @return Status
@@ -178,6 +210,23 @@ class NullFileJournal extends FileJournal {
                return Status::newGood();
        }
 
+       /**
+        * @see FileJournal::doGetCurrentPosition()
+        * @return integer|false
+        */
+       protected function doGetCurrentPosition() {
+               return false;
+       }
+
+       /**
+        * @see FileJournal::doGetPositionAtTime()
+        * @param $time integer|string timestamp
+        * @return integer|false
+        */
+       protected function doGetPositionAtTime( $time ) {
+               return false;
+       }
+
        /**
         * @see FileJournal::doGetChangeEntries()
         * @return Array
@@ -187,7 +236,7 @@ class NullFileJournal extends FileJournal {
        }
 
        /**
-        * @see FileJournal::purgeOldLogs()
+        * @see FileJournal::doPurgeOldLogs()
         * @return Status
         */
        protected function doPurgeOldLogs() {