From 31262fdf293b09dfb040738f903683ed048ac533 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 19 Jan 2006 03:59:20 +0000 Subject: [PATCH] Don't try to inflate or unserialize an error flag --- includes/Revision.php | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/includes/Revision.php b/includes/Revision.php index 437d1d85d6..c390df0636 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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; -- 2.20.1