summaryrefslogtreecommitdiff
path: root/includes/filebackend/filejournal/FileJournal.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/filebackend/filejournal/FileJournal.php')
-rw-r--r--includes/filebackend/filejournal/FileJournal.php68
1 files changed, 37 insertions, 31 deletions
diff --git a/includes/filebackend/filejournal/FileJournal.php b/includes/filebackend/filejournal/FileJournal.php
index a1b7a459..c0651485 100644
--- a/includes/filebackend/filejournal/FileJournal.php
+++ b/includes/filebackend/filejournal/FileJournal.php
@@ -36,15 +36,17 @@
* @since 1.20
*/
abstract class FileJournal {
- protected $backend; // string
- protected $ttlDays; // integer
+ /** @var string */
+ protected $backend;
+
+ /** @var int */
+ protected $ttlDays;
/**
* Construct a new instance from configuration.
- * $config includes:
- * 'ttlDays' : days to keep log entries around (false means "forever")
*
- * @param $config Array
+ * @param array $config Includes:
+ * 'ttlDays' : days to keep log entries around (false means "forever")
*/
protected function __construct( array $config ) {
$this->ttlDays = isset( $config['ttlDays'] ) ? $config['ttlDays'] : false;
@@ -53,7 +55,7 @@ abstract class FileJournal {
/**
* Create an appropriate FileJournal object from config
*
- * @param $config Array
+ * @param array $config
* @param string $backend A registered file backend name
* @throws MWException
* @return FileJournal
@@ -65,6 +67,7 @@ abstract class FileJournal {
throw new MWException( "Class given is not an instance of FileJournal." );
}
$jrn->backend = $backend;
+
return $jrn;
}
@@ -79,18 +82,18 @@ abstract class FileJournal {
$s .= mt_rand( 0, 2147483647 );
}
$s = wfBaseConvert( sha1( $s ), 16, 36, 31 );
+
return substr( wfBaseConvert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
}
/**
* Log changes made by a batch file operation.
- * $entries is an array of log entries, each of which contains:
+ *
+ * @param array $entries List of file operations (each an array of parameters) which contain:
* 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 array $entries List of file operations (each an array of parameters)
+ * Note that 'false' should be used as the SHA-1 for non-existing files.
* @param string $batchId UUID string that identifies the operation batch
* @return Status
*/
@@ -98,6 +101,7 @@ abstract class FileJournal {
if ( !count( $entries ) ) {
return Status::newGood();
}
+
return $this->doLogChangeBatch( $entries, $batchId );
}
@@ -113,7 +117,7 @@ abstract class FileJournal {
/**
* Get the position ID of the latest journal entry
*
- * @return integer|false
+ * @return int|bool
*/
final public function getCurrentPosition() {
return $this->doGetCurrentPosition();
@@ -121,15 +125,15 @@ abstract class FileJournal {
/**
* @see FileJournal::getCurrentPosition()
- * @return integer|false
+ * @return int|bool
*/
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
+ * @param int|string $time Timestamp
+ * @return int|bool
*/
final public function getPositionAtTime( $time ) {
return $this->doGetPositionAtTime( $time );
@@ -137,8 +141,8 @@ abstract class FileJournal {
/**
* @see FileJournal::getPositionAtTime()
- * @param $time integer|string timestamp
- * @return integer|false
+ * @param int|string $time Timestamp
+ * @return int|bool
*/
abstract protected function doGetPositionAtTime( $time );
@@ -146,7 +150,10 @@ abstract class FileJournal {
* Get an array of file change log entries.
* A starting change ID and/or limit can be specified.
*
- * The result as a list of associative arrays, each having:
+ * @param int $start Starting change ID or null
+ * @param int $limit Maximum number of items to return
+ * @param string &$next Updated to the ID of the next entry.
+ * @return array List of associative arrays, each having:
* id : unique, monotonic, ID for this change
* batch_uuid : UUID for an operation batch
* backend : the backend name
@@ -154,13 +161,7 @@ abstract class FileJournal {
* path : 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.
- *
- * @param $start integer Starting change ID or null
- * @param $limit integer Maximum number of items to return
- * @param &$next string
- * @return Array
+ * Also, $next is updated to the ID of the next entry.
*/
final public function getChangeEntries( $start = null, $limit = 0, &$next = null ) {
$entries = $this->doGetChangeEntries( $start, $limit ? $limit + 1 : 0 );
@@ -170,12 +171,15 @@ abstract class FileJournal {
} else {
$next = null; // end of list
}
+
return $entries;
}
/**
* @see FileJournal::getChangeEntries()
- * @return Array
+ * @param int $start
+ * @param int $limit
+ * @return array
*/
abstract protected function doGetChangeEntries( $start, $limit );
@@ -202,8 +206,8 @@ abstract class FileJournal {
class NullFileJournal extends FileJournal {
/**
* @see FileJournal::doLogChangeBatch()
- * @param $entries array
- * @param $batchId string
+ * @param array $entries
+ * @param string $batchId
* @return Status
*/
protected function doLogChangeBatch( array $entries, $batchId ) {
@@ -212,7 +216,7 @@ class NullFileJournal extends FileJournal {
/**
* @see FileJournal::doGetCurrentPosition()
- * @return integer|false
+ * @return int|bool
*/
protected function doGetCurrentPosition() {
return false;
@@ -220,8 +224,8 @@ class NullFileJournal extends FileJournal {
/**
* @see FileJournal::doGetPositionAtTime()
- * @param $time integer|string timestamp
- * @return integer|false
+ * @param int|string $time Timestamp
+ * @return int|bool
*/
protected function doGetPositionAtTime( $time ) {
return false;
@@ -229,7 +233,9 @@ class NullFileJournal extends FileJournal {
/**
* @see FileJournal::doGetChangeEntries()
- * @return Array
+ * @param int $start
+ * @param int $limit
+ * @return array
*/
protected function doGetChangeEntries( $start, $limit ) {
return array();