<?php
/**
*
- * @package MediaWiki
*/
/**
* Pure virtual parent
- * @package MediaWiki
*/
class HistoryBlob
{
/**
* setMeta and getMeta currently aren't used for anything, I just thought
* they might be useful in the future.
- * @param string $meta a single string
+ * @param $meta String: a single string.
*/
function setMeta( $meta ) {}
*/
function addItem() {}
- /**
+ /**
* Get item by hash
*/
function getItem( $hash ) {}
-
+
# Set the "default text"
# This concept is an odd property of the current DB schema, whereby each text item has a revision
- # associated with it. The default text is the text of the associated revision. There may, however,
+ # associated with it. The default text is the text of the associated revision. There may, however,
# be other revisions in the same object
function setText() {}
/**
* The real object
- * @package MediaWiki
*/
class ConcatenatedGzipHistoryBlob extends HistoryBlob
{
function ConcatenatedGzipHistoryBlob() {
if ( !function_exists( 'gzdeflate' ) ) {
- die( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
+ throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
}
}
}
/** @todo document */
- function uncompress() {
+ function uncompress() {
if ( $this->mCompressed ) {
$this->mItems = unserialize( gzinflate( $this->mItems ) );
$this->mCompressed = false;
/**
- * @package MediaWiki
*/
class HistoryBlobStub {
- var $mOldId, $mHash;
+ var $mOldId, $mHash, $mRef;
/** @todo document */
function HistoryBlobStub( $hash = '', $oldid = 0 ) {
$this->mHash = $hash;
}
-
+
/**
* Sets the location (old_id) of the main object to which this object
* points
$this->mOldId = $id;
}
+ /**
+ * Sets the location (old_id) of the referring object
+ */
+ function setReferrer( $id ) {
+ $this->mRef = $id;
+ }
+
+ /**
+ * Gets the location of the referring object
+ */
+ function getReferrer() {
+ return $this->mRef;
+ }
+
/** @todo document */
function getText() {
+ $fname = 'HistoryBlobStub::getText';
global $wgBlobCache;
if( isset( $wgBlobCache[$this->mOldId] ) ) {
$obj = $wgBlobCache[$this->mOldId];
} else {
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
if( !$row ) {
return false;
}
$flags = explode( ',', $row->old_flags );
if( in_array( 'external', $flags ) ) {
- $url=$row->old_text;
- @list($proto,$path)=explode('://',$url,2);
- if ($path=="") {
- wfProfileOut( $fname );
- return false;
- }
- require_once('ExternalStore.php');
- $row->old_text=ExternalStore::fetchFromUrl($url);
+ $url=$row->old_text;
+ @list( /* $proto */ ,$path)=explode('://',$url,2);
+ if ($path=="") {
+ wfProfileOut( $fname );
+ return false;
+ }
+ $row->old_text=ExternalStore::fetchFromUrl($url);
}
if( !in_array( 'object', $flags ) ) {
return false;
}
-
+
if( in_array( 'gzip', $flags ) ) {
// This shouldn't happen, but a bug in the compress script
// may at times gzip-compress a HistoryBlob object row.
} else {
$obj = unserialize( $row->old_text );
}
-
+
if( !is_object( $obj ) ) {
// Correct for old double-serialization bug.
$obj = unserialize( $obj );
}
-
+
// Save this item for reference; if pulling many
// items in a row we'll likely use it again.
$obj->uncompress();
* Serialized HistoryBlobCurStub objects will be inserted into the text table
* on conversion if $wgFastSchemaUpgrades is set to true.
*
- * @package MediaWiki
*/
class HistoryBlobCurStub {
var $mCurId;
function HistoryBlobCurStub( $curid = 0 ) {
$this->mCurId = $curid;
}
-
+
/**
* Sets the location (cur_id) of the main object to which this object
* points
/** @todo document */
function getText() {
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
if( !$row ) {
return false;