MediaWiki REL1_35
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)
 
 getItem ( $key)
 
 getText ()
 
 isHappy ()
 Helper function for compression jobs Returns true until the object is "full" and ready to be committed.
 
 setText ( $text)
 
 xdiffAdler32 ( $s)
 Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e.
 

Public Attributes

string $mCompressed
 Compressed storage.
 
int $mDefaultKey
 The key for getText()
 
array $mDiffMap
 The diff map, see above.
 
array $mDiffs
 Array of diffs.
 
bool $mFrozen = false
 True if the object is locked against further writes.
 
array $mItems = []
 Uncompressed item cache.
 
int $mMaxCount = 100
 The maximum number of text items before the object becomes sad.
 
int $mMaxSize = 10000000
 The maximum uncompressed size before the object becomes sad Should be less than max_allowed_packet.
 
int $mSize = 0
 Total uncompressed size.
 

Private Member Functions

 compress ()
 
 diff ( $t1, $t2)
 
 patch ( $base, $diff)
 
 uncompress ()
 

Private Attributes

const XDL_BDOP_CPY = 2
 
const XDL_BDOP_INS = 1
 Constants from xdiff.h.
 
const XDL_BDOP_INSB = 3
 

Detailed Description

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

Definition at line 27 of file DiffHistoryBlob.php.

Constructor & Destructor Documentation

◆ __construct()

DiffHistoryBlob::__construct ( )

Definition at line 71 of file DiffHistoryBlob.php.

Member Function Documentation

◆ __sleep()

DiffHistoryBlob::__sleep ( )
Returns
array

Definition at line 304 of file DiffHistoryBlob.php.

References $mDefaultKey, $mDiffs, compress(), and serialize().

◆ __wakeup()

DiffHistoryBlob::__wakeup ( )

Definition at line 331 of file DiffHistoryBlob.php.

References uncompress(), and unserialize().

◆ addItem()

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

Implements HistoryBlob.

Definition at line 82 of file DiffHistoryBlob.php.

Referenced by setText().

◆ compress()

DiffHistoryBlob::compress ( )
private
Exceptions
MWException

Definition at line 118 of file DiffHistoryBlob.php.

References diff(), and patch().

Referenced by __sleep().

◆ diff()

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

Definition at line 195 of file DiffHistoryBlob.php.

Referenced by compress().

◆ getItem()

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

Implements HistoryBlob.

Definition at line 97 of file DiffHistoryBlob.php.

Referenced by getText().

◆ getText()

DiffHistoryBlob::getText ( )
Returns
string

Implements HistoryBlob.

Definition at line 111 of file DiffHistoryBlob.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 371 of file DiffHistoryBlob.php.

References $mMaxCount.

◆ patch()

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

Definition at line 209 of file DiffHistoryBlob.php.

References $base, $header, wfDebug(), xdiffAdler32(), XDL_BDOP_CPY, XDL_BDOP_INS, and XDL_BDOP_INSB.

Referenced by compress(), and uncompress().

◆ setText()

DiffHistoryBlob::setText (   $text)
Parameters
string$text

Implements HistoryBlob.

Definition at line 104 of file DiffHistoryBlob.php.

References addItem().

◆ uncompress()

DiffHistoryBlob::uncompress ( )
private

Definition at line 287 of file DiffHistoryBlob.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 T36428.

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

Definition at line 271 of file DiffHistoryBlob.php.

References $s.

Referenced by patch().

Member Data Documentation

◆ $mCompressed

string DiffHistoryBlob::$mCompressed

Compressed storage.

Definition at line 52 of file DiffHistoryBlob.php.

◆ $mDefaultKey

int DiffHistoryBlob::$mDefaultKey

The key for getText()

Definition at line 49 of file DiffHistoryBlob.php.

Referenced by __sleep().

◆ $mDiffMap

array DiffHistoryBlob::$mDiffMap

The diff map, see above.

Definition at line 45 of file DiffHistoryBlob.php.

◆ $mDiffs

array 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 42 of file DiffHistoryBlob.php.

Referenced by __sleep().

◆ $mFrozen

bool DiffHistoryBlob::$mFrozen = false

True if the object is locked against further writes.

Definition at line 55 of file DiffHistoryBlob.php.

◆ $mItems

array DiffHistoryBlob::$mItems = []

Uncompressed item cache.

Definition at line 29 of file DiffHistoryBlob.php.

◆ $mMaxCount

int DiffHistoryBlob::$mMaxCount = 100

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

Definition at line 64 of file DiffHistoryBlob.php.

Referenced by isHappy().

◆ $mMaxSize

int DiffHistoryBlob::$mMaxSize = 10000000

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

Definition at line 61 of file DiffHistoryBlob.php.

◆ $mSize

int DiffHistoryBlob::$mSize = 0

Total uncompressed size.

Definition at line 32 of file DiffHistoryBlob.php.

◆ XDL_BDOP_CPY

const DiffHistoryBlob::XDL_BDOP_CPY = 2
private

Definition at line 68 of file DiffHistoryBlob.php.

Referenced by patch().

◆ XDL_BDOP_INS

const DiffHistoryBlob::XDL_BDOP_INS = 1
private

Constants from xdiff.h.

Definition at line 67 of file DiffHistoryBlob.php.

Referenced by patch().

◆ XDL_BDOP_INSB

const DiffHistoryBlob::XDL_BDOP_INSB = 3
private

Definition at line 69 of file DiffHistoryBlob.php.

Referenced by patch().


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