Postgres: make sure ar_len is added when updating, alpha stuff in updaters.inc
[lhc/web/wiklou.git] / includes / HistoryBlob.php
index f7fa77a..3ce4ffd 100644 (file)
@@ -1,19 +1,17 @@
 <?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 ) {}
 
@@ -31,14 +29,14 @@ class HistoryBlob
         */
        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() {}
 
@@ -50,7 +48,6 @@ class HistoryBlob
 
 /**
  * The real object
- * @package MediaWiki
  */
 class ConcatenatedGzipHistoryBlob extends HistoryBlob
 {
@@ -59,7 +56,7 @@ 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" );
                }
        }
 
@@ -111,7 +108,7 @@ class ConcatenatedGzipHistoryBlob extends HistoryBlob
        }
 
        /** @todo document */
-       function uncompress() { 
+       function uncompress() {
                if ( $this->mCompressed ) {
                        $this->mItems = unserialize( gzinflate( $this->mItems ) );
                        $this->mCompressed = false;
@@ -179,16 +176,15 @@ $wgBlobCache = array();
 
 
 /**
- * @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
@@ -197,33 +193,47 @@ class HistoryBlobStub {
                $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.
@@ -231,12 +241,12 @@ class HistoryBlobStub {
                        } 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();
@@ -260,7 +270,6 @@ class HistoryBlobStub {
  * Serialized HistoryBlobCurStub objects will be inserted into the text table
  * on conversion if $wgFastSchemaUpgrades is set to true.
  *
- * @package MediaWiki
  */
 class HistoryBlobCurStub {
        var $mCurId;
@@ -269,7 +278,7 @@ class HistoryBlobCurStub {
        function HistoryBlobCurStub( $curid = 0 ) {
                $this->mCurId = $curid;
        }
-       
+
        /**
         * Sets the location (cur_id) of the main object to which this object
         * points
@@ -280,7 +289,7 @@ class HistoryBlobCurStub {
 
        /** @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;