MediaWiki  1.23.2
DiffHistoryBlob Class Reference

Diff-based history compression Requires xdiff 1.5+ and zlib. More...

Inheritance diagram for DiffHistoryBlob:
Collaboration diagram for DiffHistoryBlob:

Public Member Functions

 __construct ()
 
 __sleep ()
 
 __wakeup ()
 
 addItem ( $text)
 
 compress ()
 
 diff ( $t1, $t2)
 
 getItem ( $key)
 
 getText ()
 
 isHappy ()
 Helper function for compression jobs Returns true until the object is "full" and ready to be committed. More...
 
 patch ( $base, $diff)
 
 setText ( $text)
 
 uncompress ()
 
 xdiffAdler32 ( $s)
 Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e. More...
 

Public Attributes

 $mCompressed
 Compressed storage. More...
 
 $mDefaultKey
 The key for getText() More...
 
 $mDiffMap
 The diff map, see above. More...
 
 $mDiffs
 Array of diffs. More...
 
 $mFrozen = false
 True if the object is locked against further writes. More...
 
 $mItems = array()
 Uncompressed item cache. More...
 
 $mMaxCount = 100
 The maximum number of text items before the object becomes sad. More...
 
 $mMaxSize = 10000000
 The maximum uncompressed size before the object becomes sad Should be less than max_allowed_packet. More...
 
 $mSize = 0
 Total uncompressed size. More...
 
const XDL_BDOP_CPY = 2
 
const XDL_BDOP_INS = 1
 Constants from xdiff.h. More...
 
const XDL_BDOP_INSB = 3
 

Detailed Description

Diff-based history compression Requires xdiff 1.5+ and zlib.

Definition at line 334 of file HistoryBlob.php.

Constructor & Destructor Documentation

◆ __construct()

DiffHistoryBlob::__construct ( )

Definition at line 385 of file HistoryBlob.php.

Member Function Documentation

◆ __sleep()

DiffHistoryBlob::__sleep ( )
Returns
array

Definition at line 617 of file HistoryBlob.php.

References $mDefaultKey, array(), as, and compress().

◆ __wakeup()

DiffHistoryBlob::__wakeup ( )

Definition at line 645 of file HistoryBlob.php.

References array(), as, and uncompress().

◆ addItem()

DiffHistoryBlob::addItem (   $text)
Exceptions
MWException
Parameters
$textstring
Returns
int

Implements HistoryBlob.

Definition at line 396 of file HistoryBlob.php.

Referenced by setText().

◆ compress()

DiffHistoryBlob::compress ( )
Exceptions
MWException

Definition at line 432 of file HistoryBlob.php.

References array(), as, diff(), and patch().

Referenced by __sleep().

◆ diff()

DiffHistoryBlob::diff (   $t1,
  $t2 
)
Parameters
$t1
$t2
Returns
string

Definition at line 509 of file HistoryBlob.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by compress().

◆ getItem()

DiffHistoryBlob::getItem (   $key)
Parameters
$keystring
Returns
string

Implements HistoryBlob.

Definition at line 411 of file HistoryBlob.php.

Referenced by getText().

◆ getText()

DiffHistoryBlob::getText ( )
Returns
string

Implements HistoryBlob.

Definition at line 425 of file HistoryBlob.php.

References getItem().

◆ isHappy()

DiffHistoryBlob::isHappy ( )

Helper function for compression jobs Returns true until the object is "full" and ready to be committed.

Returns
bool

Definition at line 685 of file HistoryBlob.php.

References $mMaxCount.

◆ patch()

DiffHistoryBlob::patch (   $base,
  $diff 
)
Parameters
$base
$diff
Returns
bool|string

Definition at line 523 of file HistoryBlob.php.

References $out, wfDebug(), wfRestoreWarnings(), wfSuppressWarnings(), xdiffAdler32(), XDL_BDOP_CPY, XDL_BDOP_INS, and XDL_BDOP_INSB.

Referenced by compress(), and uncompress().

◆ setText()

DiffHistoryBlob::setText (   $text)
Parameters
$textstring

Implements HistoryBlob.

Definition at line 418 of file HistoryBlob.php.

References addItem().

◆ uncompress()

DiffHistoryBlob::uncompress ( )

Definition at line 601 of file HistoryBlob.php.

References patch().

Referenced by __wakeup().

◆ xdiffAdler32()

DiffHistoryBlob::xdiffAdler32 (   $s)

Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e.

with the bytes backwards and initialised with 0 instead of 1. See bug 34428.

Parameters
string$s
Returns
string|bool: false if the hash extension is not available

Definition at line 585 of file HistoryBlob.php.

References $s.

Referenced by patch(), and DiffHistoryBlobTest\testXdiffAdler32().

Member Data Documentation

◆ $mCompressed

DiffHistoryBlob::$mCompressed

Compressed storage.

Definition at line 362 of file HistoryBlob.php.

◆ $mDefaultKey

DiffHistoryBlob::$mDefaultKey

The key for getText()

Definition at line 357 of file HistoryBlob.php.

Referenced by __sleep().

◆ $mDiffMap

DiffHistoryBlob::$mDiffMap

The diff map, see above.

Definition at line 352 of file HistoryBlob.php.

◆ $mDiffs

DiffHistoryBlob::$mDiffs

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

Definition at line 349 of file HistoryBlob.php.

◆ $mFrozen

DiffHistoryBlob::$mFrozen = false

True if the object is locked against further writes.

Definition at line 367 of file HistoryBlob.php.

◆ $mItems

DiffHistoryBlob::$mItems = array()

Uncompressed item cache.

Definition at line 336 of file HistoryBlob.php.

◆ $mMaxCount

DiffHistoryBlob::$mMaxCount = 100

The maximum number of text items before the object becomes sad.

Definition at line 378 of file HistoryBlob.php.

Referenced by isHappy().

◆ $mMaxSize

DiffHistoryBlob::$mMaxSize = 10000000

The maximum uncompressed size before the object becomes sad Should be less than max_allowed_packet.

Definition at line 373 of file HistoryBlob.php.

◆ $mSize

DiffHistoryBlob::$mSize = 0

Total uncompressed size.

Definition at line 339 of file HistoryBlob.php.

◆ XDL_BDOP_CPY

const DiffHistoryBlob::XDL_BDOP_CPY = 2

Definition at line 382 of file HistoryBlob.php.

Referenced by patch().

◆ XDL_BDOP_INS

const DiffHistoryBlob::XDL_BDOP_INS = 1

Constants from xdiff.h.

Definition at line 381 of file HistoryBlob.php.

Referenced by patch().

◆ XDL_BDOP_INSB

const DiffHistoryBlob::XDL_BDOP_INSB = 3

Definition at line 383 of file HistoryBlob.php.

Referenced by patch().


The documentation for this class was generated from the following file: