Don't try to inflate or unserialize an error flag
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 19 Jan 2006 03:59:20 +0000 (03:59 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 19 Jan 2006 03:59:20 +0000 (03:59 +0000)
includes/Revision.php

index 437d1d8..c390df0 100644 (file)
@@ -449,31 +449,28 @@ class Revision {
                        $text=ExternalStore::fetchFromURL($url);
                }
 
-               if( in_array( 'gzip', $flags ) ) {
-                       # Deal with optional compression of archived pages.
-                       # This can be done periodically via maintenance/compressOld.php, and
-                       # as pages are saved if $wgCompressRevisions is set.
-                       $text = gzinflate( $text );
-               }
-
-               if( in_array( 'object', $flags ) ) {
-                       # Generic compressed storage
-                       $obj = unserialize( $text );
-
-                       # Bugger, corrupted my test database by double-serializing
-                       if ( !is_object( $obj ) ) {
-                               $obj = unserialize( $obj );
+               // If the text was fetched without an error, convert it
+               if ( $text !== false ) {
+                       if( in_array( 'gzip', $flags ) ) {
+                               # Deal with optional compression of archived pages.
+                               # This can be done periodically via maintenance/compressOld.php, and
+                               # as pages are saved if $wgCompressRevisions is set.
+                               $text = gzinflate( $text );
                        }
 
-                       $text = $obj->getText();
-               }
+                       if( in_array( 'object', $flags ) ) {
+                               # Generic compressed storage
+                               $obj = unserialize( $text );
+                               $text = $obj->getText();
+                       }
 
-               global $wgLegacyEncoding;
-               if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) ) {
-                       # Old revisions kept around in a legacy encoding?
-                       # Upconvert on demand.
-                       global $wgInputEncoding, $wgContLang;
-                       $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding . '//IGNORE', $text );
+                       global $wgLegacyEncoding;
+                       if( $wgLegacyEncoding && !in_array( 'utf-8', $flags ) ) {
+                               # Old revisions kept around in a legacy encoding?
+                               # Upconvert on demand.
+                               global $wgInputEncoding, $wgContLang;
+                               $text = $wgContLang->iconv( $wgLegacyEncoding, $wgInputEncoding . '//IGNORE', $text );
+                       }
                }
                wfProfileOut( $fname );
                return $text;