diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /includes/filebackend/filejournal | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/filebackend/filejournal')
-rw-r--r-- | includes/filebackend/filejournal/DBFileJournal.php | 22 | ||||
-rw-r--r-- | includes/filebackend/filejournal/FileJournal.php | 68 |
2 files changed, 51 insertions, 39 deletions
diff --git a/includes/filebackend/filejournal/DBFileJournal.php b/includes/filebackend/filejournal/DBFileJournal.php index 9250aa5e..4f64f022 100644 --- a/includes/filebackend/filejournal/DBFileJournal.php +++ b/includes/filebackend/filejournal/DBFileJournal.php @@ -34,10 +34,9 @@ class DBFileJournal extends FileJournal { /** * Construct a new instance from configuration. - * $config includes: - * 'wiki' : wiki name to use for LoadBalancer * - * @param $config Array + * @param array $config Includes: + * 'wiki' : wiki name to use for LoadBalancer */ protected function __construct( array $config ) { parent::__construct( $config ); @@ -47,6 +46,8 @@ class DBFileJournal extends FileJournal { /** * @see FileJournal::logChangeBatch() + * @param array $entries + * @param string $batchId * @return Status */ protected function doLogChangeBatch( array $entries, $batchId ) { @@ -56,6 +57,7 @@ class DBFileJournal extends FileJournal { $dbw = $this->getMasterDB(); } catch ( DBError $e ) { $status->fatal( 'filejournal-fail-dbconnect', $this->backend ); + return $status; } @@ -80,6 +82,7 @@ class DBFileJournal extends FileJournal { } } catch ( DBError $e ) { $status->fatal( 'filejournal-fail-dbquery', $this->backend ); + return $status; } @@ -88,7 +91,7 @@ class DBFileJournal extends FileJournal { /** * @see FileJournal::doGetCurrentPosition() - * @return integer|false + * @return bool|mixed The value from the field, or false on failure. */ protected function doGetCurrentPosition() { $dbw = $this->getMasterDB(); @@ -101,13 +104,14 @@ class DBFileJournal extends FileJournal { /** * @see FileJournal::doGetPositionAtTime() - * @param $time integer|string timestamp - * @return integer|false + * @param int|string $time Timestamp + * @return bool|mixed The value from the field, or false on failure. */ 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__, @@ -117,8 +121,9 @@ class DBFileJournal extends FileJournal { /** * @see FileJournal::doGetChangeEntries() - * @return Array - * @throws DBError + * @param int $start + * @param int $limit + * @return array */ protected function doGetChangeEntries( $start, $limit ) { $dbw = $this->getMasterDB(); @@ -179,6 +184,7 @@ class DBFileJournal extends FileJournal { $this->dbw = $lb->getConnection( DB_MASTER, array(), $this->wiki ); $this->dbw->clearFlag( DBO_TRX ); } + return $this->dbw; } } 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(); |