* Moved content from liveCmdLine.inc into commandLine.inc, obsoleting the former.
[mediawiki.git] / includes / HistoryBlob.php
blobcf170b759531cc0b45208b3ae5bbe327ffe6d214
1 <?php
3 # Pure virtual parent
4 class HistoryBlob
6 function setMeta() {}
7 function getMeta() {}
8 function addItem() {}
9 function getItem() {}
12 # The real object
13 class ConcatenatedGzipHistoryBlob
15 /* private */ var $mVersion = 0, $mCompressed = false, $mItems = array();
17 function HistoryBlob() {
18 if ( !function_exists( 'gzdeflate' ) ) {
19 die( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
23 function setMeta( $metaData ) {
24 $this->uncompress();
25 $this->mItems['meta'] = $metaData;
28 function getMeta() {
29 $this->uncompress();
30 return $this->mItems['meta'];
33 function addItem( $text ) {
34 $this->uncompress();
35 $this->mItems[md5($text)] = $text;
38 function getItem( $hash ) {
39 $this->compress();
40 return $this->mItems[$hash];
43 function compress() {
44 if ( !$this->mCompressed ) {
45 $this->mItems = gzdeflate( serialize( $this->mItems ) );
46 $this->mCompressed = true;
50 function uncompress() {
51 if ( $this->mCompressed ) {
52 $this->mItems = unserialize( gzinflate( $this->mItems ) );
56 function __sleep() {
57 compress();
60 function __wakeup() {
61 uncompress();