* two-part external storage URLs. Used for represent efficient concatenated
* storage, and migration-related pointer objects.
*/
-interface HistoryBlob
-{
+interface HistoryBlob {
/**
* Adds an item of text, returns a stub object which points to the item.
* You must call setLocation() on the stub object before storing it to the
* database
*
- * @param $text string
+ * @param string $text
*
- * @return String: the key for getItem()
+ * @return string The key for getItem()
*/
function addItem( $text );
/**
* Get item by key, or false if the key is not present
*
- * @param $key string
+ * @param string $key
*
- * @return String or false
+ * @return string|bool
*/
function getItem( $key );
*
* Default text is not required for two-part external storage URLs.
*
- * @param $text string
+ * @param string $text
*/
function setText( $text );
/**
* Get default text. This is called from Revision::getRevisionText()
*
- * @return String
+ * @return string
*/
function getText();
}
* Concatenated gzip (CGZ) storage
* Improves compression ratio by concatenating like objects before gzipping
*/
-class ConcatenatedGzipHistoryBlob implements HistoryBlob
-{
+class ConcatenatedGzipHistoryBlob implements HistoryBlob {
public $mVersion = 0, $mCompressed = false, $mItems = array(), $mDefaultHash = '';
public $mSize = 0;
public $mMaxSize = 10000000;
*/
public function __construct() {
if ( !function_exists( 'gzdeflate' ) ) {
- throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
+ throw new MWException( "Need zlib support to read or write this "
+ . "kind of history object (ConcatenatedGzipHistoryBlob)\n" );
}
}
/**
- * @param $text string
+ * @param string $text
* @return string
*/
public function addItem( $text ) {
}
/**
- * @param $hash string
+ * @param string $hash
* @return array|bool
*/
public function getItem( $hash ) {
}
/**
- * @param $text string
+ * @param string $text
* @return void
*/
public function setText( $text ) {
/**
* Remove an item
*
- * @param $hash string
+ * @param string $hash
*/
public function removeItem( $hash ) {
$this->mSize -= strlen( $this->mItems[$hash] );
*/
class HistoryBlobStub {
/**
- * One-step cache variable to hold base blobs; operations that
- * pull multiple revisions may often pull multiple times from
- * the same blob. By keeping the last-used one open, we avoid
- * redundant unserialization and decompression overhead.
+ * @var array One-step cache variable to hold base blobs; operations that
+ * pull multiple revisions may often pull multiple times from the same
+ * blob. By keeping the last-used one open, we avoid redundant
+ * unserialization and decompression overhead.
*/
protected static $blobCache = array();
- var $mOldId, $mHash, $mRef;
+ /** @var int */
+ public $mOldId;
+
+ /** @var string */
+ public $mHash;
+
+ /** @var string */
+ public $mRef;
/**
- * @param string $hash the content hash of the text
- * @param $oldid Integer the old_id for the CGZ object
+ * @param string $hash The content hash of the text
+ * @param int $oldid The old_id for the CGZ object
*/
function __construct( $hash = '', $oldid = 0 ) {
$this->mHash = $hash;
/**
* Sets the location (old_id) of the main object to which this object
* points
+ * @param int $id
*/
function setLocation( $id ) {
$this->mOldId = $id;
/**
* Sets the location (old_id) of the referring object
+ * @param string $id
*/
function setReferrer( $id ) {
$this->mRef = $id;
/**
* Gets the location of the referring object
+ * @return string
*/
function getReferrer() {
return $this->mRef;
$obj = self::$blobCache[$this->mOldId];
} else {
$dbr = wfGetDB( DB_SLAVE );
- $row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
+ $row = $dbr->selectRow(
+ 'text',
+ array( 'old_flags', 'old_text' ),
+ array( 'old_id' => $this->mOldId )
+ );
+
if ( !$row ) {
return false;
}
+
$flags = explode( ',', $row->old_flags );
if ( in_array( 'external', $flags ) ) {
$url = $row->old_text;
$row->old_text = ExternalStore::fetchFromUrl( $url );
}
+
if ( !in_array( 'object', $flags ) ) {
return false;
}
$obj->uncompress();
self::$blobCache = array( $this->mOldId => $obj );
}
+
return $obj->getItem( $this->mHash );
}
* on conversion if $wgLegacySchemaConversion is set to true.
*/
class HistoryBlobCurStub {
- var $mCurId;
+ /** @var int */
+ public $mCurId;
/**
- * @param $curid Integer: the cur_id pointed to
+ * @param int $curid The cur_id pointed to
*/
function __construct( $curid = 0 ) {
$this->mCurId = $curid;
* Sets the location (cur_id) of the main object to which this object
* points
*
- * @param $id int
+ * @param int $id
*/
function setLocation( $id ) {
$this->mCurId = $id;
* Requires xdiff 1.5+ and zlib
*/
class DiffHistoryBlob implements HistoryBlob {
- /** Uncompressed item cache */
- var $mItems = array();
+ /** @var array Uncompressed item cache */
+ protected $mItems = array();
- /** Total uncompressed size */
- var $mSize = 0;
+ /** @var int Total uncompressed size */
+ protected $mSize = 0;
/**
- * Array of diffs. If a diff D from A to B is notated D = B - A, and Z is
- * an empty string:
+ * @var array Array of diffs. If a diff D from A to B is notated D = B - A,
+ * and Z is an empty string:
*
* { item[map[i]] - item[map[i-1]] where i > 0
* diff[i] = {
* { item[map[i]] - Z where i = 0
*/
- var $mDiffs;
+ protected $mDiffs;
- /** The diff map, see above */
- var $mDiffMap;
+ /** @var array The diff map, see above */
+ protected $mDiffMap;
- /**
- * The key for getText()
+ /** @var int The key for getText()
*/
- var $mDefaultKey;
+ protected $mDefaultKey;
- /**
- * Compressed storage
- */
- var $mCompressed;
+ /** @var string Compressed storage */
+ public $mCompressed;
- /**
- * True if the object is locked against further writes
- */
- var $mFrozen = false;
+ /** @var bool True if the object is locked against further writes */
+ protected $mFrozen = false;
/**
- * The maximum uncompressed size before the object becomes sad
+ * @var int The maximum uncompressed size before the object becomes sad
* Should be less than max_allowed_packet
*/
- var $mMaxSize = 10000000;
+ public $mMaxSize = 10000000;
- /**
- * The maximum number of text items before the object becomes sad
- */
- var $mMaxCount = 100;
+ /** @var int The maximum number of text items before the object becomes sad */
+ public $mMaxCount = 100;
/** Constants from xdiff.h */
const XDL_BDOP_INS = 1;
/**
* @throws MWException
- * @param $text string
+ * @param string $text
* @return int
*/
function addItem( $text ) {
}
/**
- * @param $key string
+ * @param string $key
* @return string
*/
function getItem( $key ) {
}
/**
- * @param $text string
+ * @param string $text
*/
function setText( $text ) {
$this->mDefaultKey = $this->addItem( $text );
);
$smallFactor = 0.5;
- for ( $i = 0; $i < count( $this->mItems ); $i++ ) {
+ $mItemsCount = count( $this->mItems );
+ for ( $i = 0; $i < $mItemsCount; $i++ ) {
$text = $this->mItems[$i];
if ( $i == 0 ) {
$seqName = 'main';
$this->mDiffs[] = $this->diff( $tail, $head );
}
$this->mDiffMap[] = $seq['map'][0];
- for ( $i = 1; $i < count( $seq['diffs'] ); $i++ ) {
+ $diffsCount = count( $seq['diffs'] );
+ for ( $i = 1; $i < $diffsCount; $i++ ) {
$this->mDiffs[] = $seq['diffs'][$i];
$this->mDiffMap[] = $seq['map'][$i];
}
}
/**
- * @param $t1
- * @param $t2
+ * @param string $t1
+ * @param string $t2
* @return string
*/
function diff( $t1, $t2 ) {
}
/**
- * @param $base
- * @param $diff
+ * @param string $base
+ * @param string $diff
* @return bool|string
*/
function patch( $base, $diff ) {
* the bytes backwards and initialised with 0 instead of 1. See bug 34428.
*
* @param string $s
- * @return string|bool: false if the hash extension is not available
+ * @return string|bool False if the hash extension is not available
*/
function xdiffAdler32( $s ) {
if ( !function_exists( 'hash' ) ) {
return;
}
$tail = '';
- for ( $diffKey = 0; $diffKey < count( $this->mDiffs ); $diffKey++ ) {
+ $mDiffsCount = count( $this->mDiffs );
+ for ( $diffKey = 0; $diffKey < $mDiffsCount; $diffKey++ ) {
$textKey = $this->mDiffMap[$diffKey];
$text = $this->patch( $tail, $this->mDiffs[$diffKey] );
$this->mItems[$textKey] = $text;