Followup r86622: add initial QUnit test cases for jquery.textSelection module.
[lhc/web/wiklou.git] / includes / HistoryBlob.php
index 6e20b0f..f707b3f 100644 (file)
@@ -12,6 +12,8 @@ interface HistoryBlob
         * You must call setLocation() on the stub object before storing it to the
         * database
         *
+        * @param $text string
+        *
         * @return String: the key for getItem()
         */
        function addItem( $text );
@@ -19,6 +21,8 @@ interface HistoryBlob
        /**
         * Get item by key, or false if the key is not present
         *
+        * @param $key string
+        *
         * @return String or false
         */
        function getItem( $key );
@@ -30,6 +34,8 @@ interface HistoryBlob
         * be other revisions in the same object.
         *
         * Default text is not required for two-part external storage URLs.
+        *
+        * @param $text string
         */
        function setText( $text );
 
@@ -53,12 +59,16 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
        public $mMaxCount = 100;
 
        /** Constructor */
-       public function ConcatenatedGzipHistoryBlob() {
+       public function __construct() {
                if ( !function_exists( 'gzdeflate' ) ) {
                        throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
                }
        }
 
+       /**
+        * @param $text string
+        * @return string
+        */
        public function addItem( $text ) {
                $this->uncompress();
                $hash = md5( $text );
@@ -69,6 +79,10 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
                return $hash;
        }
 
+       /**
+        * @param $hash string
+        * @return array|bool
+        */
        public function getItem( $hash ) {
                $this->uncompress();
                if ( array_key_exists( $hash, $this->mItems ) ) {
@@ -78,11 +92,18 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
                }
        }
 
+       /**
+        * @param $text string
+        * @return void
+        */
        public function setText( $text ) {
                $this->uncompress();
                $this->mDefaultHash = $this->addItem( $text );
        }
 
+       /**
+        * @return array|bool
+        */
        public function getText() {
                $this->uncompress();
                return $this->getItem( $this->mDefaultHash );
@@ -90,6 +111,8 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
 
        /**
         * Remove an item
+        *
+        * @param $hash string
         */
        public function removeItem( $hash ) {
                $this->mSize -= strlen( $this->mItems[$hash] );
@@ -116,7 +139,9 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
                }
        }
 
-
+       /**
+        * @return array
+        */
        function __sleep() {
                $this->compress();
                return array( 'mVersion', 'mCompressed', 'mItems', 'mDefaultHash' );
@@ -129,6 +154,8 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
        /**
         * Helper function for compression jobs
         * Returns true until the object is "full" and ready to be committed
+        *
+        * @return bool
         */
        public function isHappy() {
                return $this->mSize < $this->mMaxSize 
@@ -137,8 +164,6 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
 }
 
 
-
-
 /**
  * Pointer object for an item within a CGZ blob stored in the text table.
  */
@@ -183,6 +208,9 @@ class HistoryBlobStub {
                return $this->mRef;
        }
 
+       /**
+        * @return string
+        */
        function getText() {
                $fname = 'HistoryBlobStub::getText';
 
@@ -197,12 +225,12 @@ class HistoryBlobStub {
                        $flags = explode( ',', $row->old_flags );
                        if( in_array( 'external', $flags ) ) {
                                $url=$row->old_text;
-                               @list( /* $proto */ ,$path)=explode('://',$url,2);
-                               if ($path=="") {
+                               $parts = explode( '://', $url, 2 );
+                               if ( !isset( $parts[1] ) || $parts[1] == '' ) {
                                        wfProfileOut( $fname );
                                        return false;
                                }
-                               $row->old_text=ExternalStore::fetchFromUrl($url);
+                               $row->old_text = ExternalStore::fetchFromUrl($url);
 
                        }
                        if( !in_array( 'object', $flags ) ) {
@@ -232,6 +260,8 @@ class HistoryBlobStub {
 
        /**
         * Get the content hash
+        *
+        * @return string
         */
        function getHash() {
                return $this->mHash;
@@ -260,11 +290,16 @@ class HistoryBlobCurStub {
        /**
         * Sets the location (cur_id) of the main object to which this object
         * points
+        *
+        * @param $id int
         */
        function setLocation( $id ) {
                $this->mCurId = $id;
        }
 
+       /**
+        * @return string|false
+        */
        function getText() {
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
@@ -336,6 +371,11 @@ class DiffHistoryBlob implements HistoryBlob {
                }
        }
 
+       /**
+        * @throws MWException
+        * @param $text string
+        * @return int
+        */
        function addItem( $text ) {
                if ( $this->mFrozen ) {
                        throw new MWException( __METHOD__.": Cannot add more items after sleep/wakeup" );
@@ -347,18 +387,31 @@ class DiffHistoryBlob implements HistoryBlob {
                return count( $this->mItems ) - 1;
        }
 
+       /**
+        * @param $key string
+        * @return string
+        */
        function getItem( $key ) {
                return $this->mItems[$key];
        }
 
+       /**
+        * @param $text string
+        */
        function setText( $text ) {
                $this->mDefaultKey = $this->addItem( $text );
        }
 
+       /**
+        * @return string
+        */
        function getText() {
                return $this->getItem( $this->mDefaultKey );
        }
 
+       /**
+        * @throws MWException
+        */
        function compress() {
                if ( !function_exists( 'xdiff_string_rabdiff' ) ){ 
                        throw new MWException( "Need xdiff 1.5+ support to write DiffHistoryBlob\n" );
@@ -431,6 +484,11 @@ class DiffHistoryBlob implements HistoryBlob {
                }
        }
 
+       /**
+        * @param $t1
+        * @param $t2
+        * @return string
+        */
        function diff( $t1, $t2 ) {
                # Need to do a null concatenation with warnings off, due to bugs in the current version of xdiff
                # "String is not zero-terminated"
@@ -440,6 +498,11 @@ class DiffHistoryBlob implements HistoryBlob {
                return $diff;
        }
 
+       /**
+        * @param $base
+        * @param $diff
+        * @return bool|string
+        */
        function patch( $base, $diff ) {
                if ( function_exists( 'xdiff_string_bpatch' ) ) {
                        wfSuppressWarnings();
@@ -510,6 +573,9 @@ class DiffHistoryBlob implements HistoryBlob {
                }
        }
 
+       /**
+        * @return array
+        */
        function __sleep() {
                $this->compress();
                if ( !count( $this->mItems ) ) {
@@ -575,6 +641,8 @@ class DiffHistoryBlob implements HistoryBlob {
        /**
         * Helper function for compression jobs
         * Returns true until the object is "full" and ready to be committed
+        *
+        * @return bool
         */
        function isHappy() {
                return $this->mSize < $this->mMaxSize