From 4de24de85f25c9cbb9d078f16d2df021a8c0cff1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 5 May 2005 23:27:34 +0000 Subject: [PATCH] * Fix for reading incorrectly re-gzipped HistoryBlob entries --- RELEASE-NOTES | 1 + includes/HistoryBlob.php | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 06ce3e6e5a..266077b324 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index b9df3d6c3f..2fe5d1f5d0 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -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 +?> -- 2.20.1