X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FHistoryBlob.php;h=867312555096295177543b58885e9ffb55755410;hp=69f1120d43f6df9bedb4349478228fb0454e1d11;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hpb=7a7f79394e70402c567dad068a7701e021b395d3 diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 69f1120d43..8673125550 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -71,7 +71,7 @@ interface HistoryBlob { * 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; @@ -165,7 +165,7 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob { */ function __sleep() { $this->compress(); - return array( 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' ); + return [ 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' ]; } function __wakeup() { @@ -194,7 +194,7 @@ class HistoryBlobStub { * 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; @@ -248,8 +248,8 @@ class HistoryBlobStub { $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'text', - array( 'old_flags', 'old_text' ), - array( 'old_id' => $this->mOldId ) + [ 'old_flags', 'old_text' ], + [ 'old_id' => $this->mOldId ] ); if ( !$row ) { @@ -263,7 +263,7 @@ class HistoryBlobStub { if ( !isset( $parts[1] ) || $parts[1] == '' ) { return false; } - $row->old_text = ExternalStore::fetchFromUrl( $url ); + $row->old_text = ExternalStore::fetchFromURL( $url ); } @@ -287,7 +287,7 @@ class HistoryBlobStub { // 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 ); @@ -337,7 +337,7 @@ class HistoryBlobCurStub { */ function getText() { $dbr = wfGetDB( DB_SLAVE ); - $row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) ); + $row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] ); if ( !$row ) { return false; } @@ -351,7 +351,7 @@ class HistoryBlobCurStub { */ class DiffHistoryBlob implements HistoryBlob { /** @var array Uncompressed item cache */ - public $mItems = array(); + public $mItems = []; /** @var int Total uncompressed size */ public $mSize = 0; @@ -454,18 +454,18 @@ class DiffHistoryBlob implements HistoryBlob { } // 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 ); @@ -492,8 +492,8 @@ class DiffHistoryBlob implements HistoryBlob { // Knit the sequences together $tail = ''; - $this->mDiffs = array(); - $this->mDiffMap = array(); + $this->mDiffs = []; + $this->mDiffMap = []; foreach ( $sequences as $seq ) { if ( !count( $seq['diffs'] ) ) { continue; @@ -522,9 +522,9 @@ class DiffHistoryBlob implements HistoryBlob { function diff( $t1, $t2 ) { # Need to do a null concatenation with warnings off, due to bugs in the current version of xdiff # "String is not zero-terminated" - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); $diff = xdiff_string_rabdiff( $t1, $t2 ) . ''; - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); return $diff; } @@ -535,9 +535,9 @@ class DiffHistoryBlob implements HistoryBlob { */ function patch( $base, $diff ) { if ( function_exists( 'xdiff_string_bpatch' ) ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); $text = xdiff_string_bpatch( $base, $diff ) . ''; - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); return $text; } @@ -644,16 +644,16 @@ class DiffHistoryBlob implements HistoryBlob { $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() { @@ -681,7 +681,7 @@ class DiffHistoryBlob implements HistoryBlob { // New format $map = explode( ',', $info['map'] ); $cur = 0; - $this->mDiffMap = array(); + $this->mDiffMap = []; foreach ( $map as $i ) { $cur += $i; $this->mDiffMap[] = $cur;