* Improves compression ratio by concatenating like objects before gzipping
*/
class ConcatenatedGzipHistoryBlob implements HistoryBlob {
- public $mVersion = 0, $mCompressed = false, $mItems = array(), $mDefaultHash = '';
+ public $mVersion = 0, $mCompressed = false, $mItems = [], $mDefaultHash = '';
public $mSize = 0;
public $mMaxSize = 10000000;
public $mMaxCount = 100;
*/
function __sleep() {
$this->compress();
- return array( 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' );
+ return [ 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' ];
}
function __wakeup() {
* blob. By keeping the last-used one open, we avoid redundant
* unserialization and decompression overhead.
*/
- protected static $blobCache = array();
+ protected static $blobCache = [];
/** @var int */
public $mOldId;
if ( isset( self::$blobCache[$this->mOldId] ) ) {
$obj = self::$blobCache[$this->mOldId];
} else {
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'text',
- array( 'old_flags', 'old_text' ),
- array( 'old_id' => $this->mOldId )
+ [ 'old_flags', 'old_text' ],
+ [ 'old_id' => $this->mOldId ]
);
if ( !$row ) {
if ( !isset( $parts[1] ) || $parts[1] == '' ) {
return false;
}
- $row->old_text = ExternalStore::fetchFromUrl( $url );
+ $row->old_text = ExternalStore::fetchFromURL( $url );
}
// Save this item for reference; if pulling many
// items in a row we'll likely use it again.
$obj->uncompress();
- self::$blobCache = array( $this->mOldId => $obj );
+ self::$blobCache = [ $this->mOldId => $obj ];
}
return $obj->getItem( $this->mHash );
* @return string|bool
*/
function getText() {
- $dbr = wfGetDB( DB_SLAVE );
- $row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
+ $dbr = wfGetDB( DB_REPLICA );
+ $row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] );
if ( !$row ) {
return false;
}
*/
class DiffHistoryBlob implements HistoryBlob {
/** @var array Uncompressed item cache */
- public $mItems = array();
+ public $mItems = [];
/** @var int Total uncompressed size */
public $mSize = 0;
}
// Create two diff sequences: one for main text and one for small text
- $sequences = array(
- 'small' => array(
+ $sequences = [
+ 'small' => [
'tail' => '',
- 'diffs' => array(),
- 'map' => array(),
- ),
- 'main' => array(
+ 'diffs' => [],
+ 'map' => [],
+ ],
+ 'main' => [
'tail' => '',
- 'diffs' => array(),
- 'map' => array(),
- ),
- );
+ 'diffs' => [],
+ 'map' => [],
+ ],
+ ];
$smallFactor = 0.5;
$mItemsCount = count( $this->mItems );
// Knit the sequences together
$tail = '';
- $this->mDiffs = array();
- $this->mDiffMap = array();
+ $this->mDiffs = [];
+ $this->mDiffMap = [];
foreach ( $sequences as $seq ) {
if ( !count( $seq['diffs'] ) ) {
continue;
$map .= $i - $prev;
$prev = $i;
}
- $info = array(
+ $info = [
'diffs' => $this->mDiffs,
'map' => $map
- );
+ ];
}
if ( isset( $this->mDefaultKey ) ) {
$info['default'] = $this->mDefaultKey;
}
$this->mCompressed = gzdeflate( serialize( $info ) );
- return array( 'mCompressed' );
+ return [ 'mCompressed' ];
}
function __wakeup() {
// New format
$map = explode( ',', $info['map'] );
$cur = 0;
- $this->mDiffMap = array();
+ $this->mDiffMap = [];
foreach ( $map as $i ) {
$cur += $i;
$this->mDiffMap[] = $cur;