* Fix for reading incorrectly re-gzipped HistoryBlob entries
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 5 May 2005 23:27:34 +0000 (23:27 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 5 May 2005 23:27:34 +0000 (23:27 +0000)
RELEASE-NOTES
includes/HistoryBlob.php

index 06ce3e6..266077b 100644 (file)
@@ -162,6 +162,7 @@ Various bugfixes, small features, and a few experimental things:
 * ...various...
 * (bug 2067) Fixed crash on empty quoted HTML attribute
 * (bug 2079) Removed links to Special:Maintenance from movepagetext messages
+* Fix for reading incorrectly re-gzipped HistoryBlob entries
 
 
 === Caveats ===
index b9df3d6..2fe5d1f 100644 (file)
@@ -190,11 +190,24 @@ class HistoryBlobStub {
        function getText() {
                $dbr =& wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
-               if ( !$row || $row->old_flags != 'object' ) {
+               if( !$row ) {
                        return false;
                }
-               $obj = unserialize( $row->old_text );
-               if ( !is_object( $obj ) ) {
+               $flags = explode( ',', $row->old_flags );
+               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.
+                       $obj = unserialize( gzinflate( $row->old_text ) );
+               } else {
+                       $obj = unserialize( $row->old_text );
+               }
+               
+               if( !is_object( $obj ) ) {
+                       // Correct for old double-serialization bug.
                        $obj = unserialize( $obj );
                }
                return $obj->getItem( $this->mHash );
@@ -205,4 +218,4 @@ class HistoryBlobStub {
                return $this->mHash;
        }
 }
-?>
\ No newline at end of file
+?>