From 212ae934cd0f53c117a512d52ce5cacde478ed57 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 31 Jul 2019 12:16:07 +1000 Subject: [PATCH] Revert rename of mSpeculativeRevId to speculativeRevIdUsed And add a test which is confirmed to fail on HHVM prior to this change with the error message "serialize(): "" returned as member variable from __sleep() but does not exist". Bug: T229366 Change-Id: I236bb4d64bc2e9f7756885e8c418399804eac5e1 --- includes/parser/ParserOutput.php | 8 ++++---- .../includes/parser/ParserOutputTest.php | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index dcb5444502..cbba80a51b 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -213,12 +213,12 @@ class ParserOutput extends CacheTime { /** @var string[] */ private static $speculativeFields = [ 'speculativePageIdUsed', - 'speculativeRevIdUsed', + 'mSpeculativeRevId', 'revisionTimestampUsed' ]; /** @var int|null Assumed rev ID for {{REVISIONID}} if no revision is set */ - private $speculativeRevIdUsed; + private $mSpeculativeRevId; /** @var int|null Assumed page ID for {{PAGEID}} if no revision is set */ private $speculativePageIdUsed; /** @var int|null Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set */ @@ -448,7 +448,7 @@ class ParserOutput extends CacheTime { * @since 1.28 */ public function setSpeculativeRevIdUsed( $id ) { - $this->speculativeRevIdUsed = $id; + $this->mSpeculativeRevId = $id; } /** @@ -456,7 +456,7 @@ class ParserOutput extends CacheTime { * @since 1.28 */ public function getSpeculativeRevIdUsed() { - return $this->speculativeRevIdUsed; + return $this->mSpeculativeRevId; } /** diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php index 34ddb1f1fd..ec60383ed7 100644 --- a/tests/phpunit/includes/parser/ParserOutputTest.php +++ b/tests/phpunit/includes/parser/ParserOutputTest.php @@ -939,4 +939,24 @@ EOF $this->assertSame( $time, $po->getCacheTime() ); } + public static function provideOldSerialized() { + return [ + // phpcs:ignore Generic.Files.LineLength + '1.34.0-wmf.15' => [ 'O:12:"ParserOutput":43:{s:5:"mText";s:0:"";s:14:"mLanguageLinks";a:0:{}s:11:"mCategories";a:0:{}s:11:"mIndicators";a:0:{}s:10:"mTitleText";s:0:"";s:6:"mLinks";a:0:{}s:10:"mTemplates";a:0:{}s:12:"mTemplateIds";a:0:{}s:7:"mImages";a:0:{}s:18:"mFileSearchOptions";a:0:{}s:14:"mExternalLinks";a:0:{}s:15:"mInterwikiLinks";a:0:{}s:11:"mNewSection";b:0;s:15:"mHideNewSection";b:0;s:10:"mNoGallery";b:0;s:10:"mHeadItems";a:0:{}s:8:"mModules";a:0:{}s:13:"mModuleStyles";a:0:{}s:13:"mJsConfigVars";a:0:{}s:12:"mOutputHooks";a:0:{}s:9:"mWarnings";a:0:{}s:9:"mSections";a:0:{}s:11:"mProperties";a:0:{}s:8:"mTOCHTML";s:0:"";s:10:"mTimestamp";N;s:11:"mEnableOOUI";b:0;s:26:"\\000ParserOutput\\000mIndexPolicy";s:0:"";s:30:"\\000ParserOutput\\000mAccessedOptions";a:0:{}s:28:"\\000ParserOutput\\000mExtensionData";a:0:{}s:30:"\\000ParserOutput\\000mLimitReportData";a:0:{}s:32:"\\000ParserOutput\\000mLimitReportJSData";a:0:{}s:34:"\\000ParserOutput\\000mPreventClickjacking";b:0;s:20:"\\000ParserOutput\\000mFlags";a:0:{}s:31:"\\000ParserOutput\\000mSpeculativeRevId";N;s:35:"\\000ParserOutput\\000revisionTimestampUsed";N;s:36:"\\000ParserOutput\\000revisionUsedSha1Base36";N;s:32:"\\000ParserOutput\\000mWrapperDivClasses";a:0:{}s:32:"\\000ParserOutput\\000mMaxAdaptiveExpiry";d:INF;s:12:"mUsedOptions";N;s:8:"mVersion";s:5:"1.6.4";s:10:"mCacheTime";s:0:"";s:12:"mCacheExpiry";N;s:16:"mCacheRevisionId";N;}' ] + ]; + } + + /** + * Ensure that old ParserOutput objects can be unserialized and reserialized without an error + * (T229366). + * + * @dataProvider provideOldSerialized + * @covers ParserOutput::__sleep() + */ + public function testOldSerialized( $serialized ) { + $po = unserialize( stripcslashes( $serialized ) ); + $reserialized = serialize( $po ); + $this->assertStringStartsWith( 'O:', $reserialized ); + } + } -- 2.20.1