From a1aa3e0827f9d74c66feb9a9faef2873a0cd6855 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Mon, 9 Nov 2020 18:47:09 -0700 Subject: [PATCH] Hard-deprecate all public property access on CacheTime and ParserOutput. - Added a test where ParserOutput objects with CacheTime properties set are unserialized from previous versions. - Generate new serialization tests for 1.38 Now all serialization in production is JSON, so changing property visibility shouldn't affect ParserCache. Bug: T263851 Depends-On: I283340ff559420ceee8f286ba3ef202c01206a23 Change-Id: I70d6feb1c995a0a0f763b21261141ae8ee6dc570 --- RELEASE-NOTES-1.38 | 2 + includes/parser/CacheTime.php | 33 ++++++- includes/parser/ParserOutput.php | 81 ++++++++++++------ .../1.36-ParserOutput-cacheTime.json | 1 + .../1.36-ParserOutput-cacheTime.serialized | Bin 0 -> 1899 bytes .../1.36_wmf.18-ParserOutput-cacheTime.json | 1 + ...6_wmf.18-ParserOutput-cacheTime.serialized | Bin 0 -> 1533 bytes .../1.38-CacheTime-cacheExpiry.serialized | Bin 0 -> 139 bytes .../1.38-CacheTime-cacheRevisionId.serialized | Bin 0 -> 141 bytes .../1.38-CacheTime-cacheTime.serialized | Bin 0 -> 151 bytes .../1.38-CacheTime-empty.serialized | Bin 0 -> 136 bytes .../1.38-CacheTime-usedOptions.serialized | Bin 0 -> 166 bytes ...rserOutput-binaryPageProperties.serialized | Bin 0 -> 1934 bytes .../1.38-ParserOutput-cacheTime.json | 1 + .../1.38-ParserOutput-cacheTime.serialized | Bin 0 -> 1868 bytes .../1.38-ParserOutput-empty.serialized | Bin 0 -> 1838 bytes ...1.38-ParserOutput-extensionData.serialized | Bin 0 -> 1980 bytes ....38-ParserOutput-pageProperties.serialized | Bin 0 -> 1993 bytes .../1.38-ParserOutput-text.serialized | Bin 0 -> 1850 bytes .../1.38-ParserOutput-usedOptions.serialized | Bin 0 -> 1873 bytes .../1.38-ParserOutput-withMetadata.serialized | Bin 0 -> 2744 bytes ...rserOutput-withMetadataPost1_31.serialized | Bin 0 -> 1901 bytes ...rserOutput-withMetadataPost1_34.serialized | Bin 0 -> 1908 bytes .../serialization/SerializationTestUtils.php | 2 + .../ParserCacheSerializationTestCases.php | 22 ++++- ...lidateParserCacheSerializationTestData.php | 4 +- 26 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.json create mode 100644 tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.serialized create mode 100644 tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.json create mode 100644 tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-CacheTime-cacheExpiry.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-CacheTime-cacheRevisionId.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-CacheTime-cacheTime.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-CacheTime-empty.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-CacheTime-usedOptions.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-binaryPageProperties.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-cacheTime.json create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-cacheTime.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-empty.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-extensionData.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-pageProperties.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-text.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-usedOptions.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadata.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadataPost1_31.serialized create mode 100644 tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadataPost1_34.serialized diff --git a/RELEASE-NOTES-1.38 b/RELEASE-NOTES-1.38 index 8176cba5dfb..41d69f38427 100644 --- a/RELEASE-NOTES-1.38 +++ b/RELEASE-NOTES-1.38 @@ -210,6 +210,8 @@ because of Phabricator reports. * Return values in the parameter $pageLang of the hook PageContentLanguage with other types than a Language object, deprecated since 1.33, now emmits deprecation warnings. +* All external access to ParserOutput and CacheTime classes properties + was hard-deprecated. Use getters and setters instead. * … === Other changes in 1.38 === diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php index 4364a971407..df4b1f88adb 100644 --- a/includes/parser/CacheTime.php +++ b/includes/parser/CacheTime.php @@ -46,18 +46,18 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable { * @var string|int TS_MW timestamp when this object was generated, or -1 for not cacheable. Used * in ParserCache. */ - public $mCacheTime = ''; + protected $mCacheTime = ''; /** * @var int|null Seconds after which the object should expire, use 0 for not cacheable. Used in * ParserCache. */ - public $mCacheExpiry = null; + protected $mCacheExpiry = null; /** * @var int|null Revision ID that was parsed */ - public $mCacheRevisionId = null; + protected $mCacheRevisionId = null; /** * @return string|int TS_MW timestamp @@ -292,4 +292,31 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable { $this->recordOptions( $priorOptions ); } } + + public function __get( $name ) { + if ( property_exists( get_called_class(), $name ) ) { + // Direct access to a public property, deprecated. + wfDeprecatedMsg( "CacheTime::{$name} public read access deprecated", '1.38' ); + return $this->$name; + } elseif ( property_exists( $this, $name ) ) { + // Dynamic property access, deprecated. + wfDeprecatedMsg( "CacheTime::{$name} dynamic property read access deprecated", '1.38' ); + return $this->$name; + } else { + trigger_error( "Inaccessible property via __set(): $name" ); + return null; + } + } + + public function __set( $name, $value ) { + if ( property_exists( get_called_class(), $name ) ) { + // Direct access to a public property, deprecated. + wfDeprecatedMsg( "CacheTime::$name public write access deprecated", '1.38' ); + $this->$name = $value; + } else { + // Dynamic property access, deprecated. + wfDeprecatedMsg( "CacheTime::$name dynamic property write access deprecated", '1.38' ); + $this->$name = $value; + } + } } diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index ce1170973fc..279bdcd359a 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -49,145 +49,145 @@ class ParserOutput extends CacheTime { /** * @var string|null The output text */ - public $mText = null; + private $mText = null; /** * @var array List of the full text of language links, * in the order they appear. */ - public $mLanguageLinks; + private $mLanguageLinks; /** * @var array Map of category names to sort keys */ - public $mCategories; + private $mCategories; /** * @var array Page status indicators, usually displayed in top-right corner. */ - public $mIndicators = []; + private $mIndicators = []; /** * @var string Title text of the chosen language variant, as HTML. */ - public $mTitleText; + private $mTitleText; /** * @var int[][] 2-D map of NS/DBK to ID for the links in the document. * ID=zero for broken. * @phan-var array> */ - public $mLinks = []; + private $mLinks = []; /** * @var array Keys are DBKs for the links to special pages in the document. * @since 1.35 */ - public $mLinksSpecial = []; + private $mLinksSpecial = []; /** * @var array 2-D map of NS/DBK to ID for the template references. * ID=zero for broken. */ - public $mTemplates = []; + private $mTemplates = []; /** * @var array 2-D map of NS/DBK to rev ID for the template references. * ID=zero for broken. */ - public $mTemplateIds = []; + private $mTemplateIds = []; /** * @var array DB keys of the images used, in the array key only */ - public $mImages = []; + private $mImages = []; /** * @var array DB keys of the images used mapped to sha1 and MW timestamp. */ - public $mFileSearchOptions = []; + private $mFileSearchOptions = []; /** * @var array External link URLs, in the key only. */ - public $mExternalLinks = []; + private $mExternalLinks = []; /** * @var array 2-D map of prefix/DBK (in keys only) * for the inline interwiki links in the document. */ - public $mInterwikiLinks = []; + private $mInterwikiLinks = []; /** * @var bool Show a new section link? */ - public $mNewSection = false; + private $mNewSection = false; /** * @var bool Hide the new section link? */ - public $mHideNewSection = false; + private $mHideNewSection = false; /** * @var bool No gallery on category page? (__NOGALLERY__). */ - public $mNoGallery = false; + private $mNoGallery = false; /** * @var array Items to put in the section */ - public $mHeadItems = []; + private $mHeadItems = []; /** * @var array Modules to be loaded by ResourceLoader */ - public $mModules = []; + private $mModules = []; /** * @var array Modules of which only the CSSS will be loaded by ResourceLoader. */ - public $mModuleStyles = []; + private $mModuleStyles = []; /** * @var array JavaScript config variable for mw.config combined with this page. */ - public $mJsConfigVars = []; + private $mJsConfigVars = []; /** * @var array Hook tags as per $wgParserOutputHooks. */ - public $mOutputHooks = []; + private $mOutputHooks = []; /** * @var array Warning text to be returned to the user. * Wikitext formatted, in the key only. */ - public $mWarnings = []; + private $mWarnings = []; /** * @var array Table of contents */ - public $mSections = []; + private $mSections = []; /** * @var array Name/value pairs to be cached in the DB. */ - public $mProperties = []; + private $mProperties = []; /** * @var string HTML of the TOC. */ - public $mTOCHTML = ''; + private $mTOCHTML = ''; /** * @var string Timestamp of the revision. */ - public $mTimestamp; + private $mTimestamp; /** * @var bool Whether OOUI should be enabled. */ - public $mEnableOOUI = false; + private $mEnableOOUI = false; /** * @var string 'index' or 'noindex'? Any other value will result in no change. @@ -1950,4 +1950,31 @@ class ParserOutput extends CacheTime { $this->mParseUsedOptions = $priorAccessedOptions; } } + + public function __get( $name ) { + if ( property_exists( get_called_class(), $name ) ) { + // Direct access to a public property, deprecated. + wfDeprecatedMsg( "ParserOutput::{$name} public read access deprecated", '1.38' ); + return $this->$name; + } elseif ( property_exists( $this, $name ) ) { + // Dynamic property access, deprecated. + wfDeprecatedMsg( "ParserOutput::{$name} dynamic property read access deprecated", '1.38' ); + return $this->$name; + } else { + trigger_error( "Inaccessible property via __set(): $name" ); + return null; + } + } + + public function __set( $name, $value ) { + if ( property_exists( get_called_class(), $name ) ) { + // Direct access to a public property, deprecated. + wfDeprecatedMsg( "ParserOutput::$name public write access deprecated", '1.38' ); + $this->$name = $value; + } else { + // Dynamic property access, deprecated. + wfDeprecatedMsg( "ParserOutput::$name dynamic property write access deprecated", '1.38' ); + $this->$name = $value; + } + } } diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.json new file mode 100644 index 00000000000..faf928aaea4 --- /dev/null +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.json @@ -0,0 +1 @@ +{"Text":"CacheTime","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"ParseUsedOptions":[],"CacheExpiry":10,"CacheTime":"20010419042521","CacheRevisionId":42,"Version":"1.6.4","_type_":"ParserOutput"} \ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.serialized b/tests/phpunit/data/ParserCache/1.36-ParserOutput-cacheTime.serialized new file mode 100644 index 0000000000000000000000000000000000000000..747868668120ab1ca45c2f779ce9a12c9d41f39c GIT binary patch literal 1899 zcmai#+j8145QcdcU-ly710jvLY7G=;I898F>y5nu75Ol-AY?Lm_ey|4c-{62Gx}z= z`~SPEIrDtxEI?K$=UY{7mBYGs?6YFtJ##wtK_^?{UOD}W>5~wWH7+=y8zbPaZ1JrZttqN3F1JiOE$Yeb)6)$p&ZZTrG zS15B3&5EhJQLf2%zTr)jdN#xN7!z~3(|={IX#pB<%u{Ruse-fO7YKp!;~b1KV}vwP znAycrX{JTG6}EgnHTKBF>f?XlLlqYJ8(%%^;jlV@dV8FkaZy}#dO(bO0h#lBWe20s zNmm=9`Y&WrqEy#2L*-b`!|`%DF*8t)0#()wait(Do&L-iNpBnG@G5XVe~QiqQ4#cf z;(k#Go@g5{_tDK@8ZxhR>kL4_Mc1HhNHeY;u`Hx&u(Z?(KeG>UgQhhvB=e0ydL_3_oC=IOTaUDtEF-o4xPZ+-888a->YPJ}bh?7+i|S)XYS4$2uL JIP3cTuRlu`cf0@q literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.json b/tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.json new file mode 100644 index 00000000000..1f75ae54239 --- /dev/null +++ b/tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.json @@ -0,0 +1 @@ +{"Text":"CacheTime","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":10,"CacheTime":"20010419042521","CacheRevisionId":42,"Version":"1.6.4","_type_":"ParserOutput"} \ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.serialized b/tests/phpunit/data/ParserCache/1.36_wmf.18-ParserOutput-cacheTime.serialized new file mode 100644 index 0000000000000000000000000000000000000000..464b503aed31edf99f63399e0cb840f2e50a2d7f GIT binary patch literal 1533 zcmZ`(+fw2{5cON~0ag+stHYBUV2Oo58Pw-CXsY>$p5{7l2gc6TUg;#=9|hH zfN;gvH|0FagAal&3NQQ)oNkaw};RHvK5TZTj4$RlV25;t~@H%4%Gf!K_r& z+%8WG(k6#^lv|yP0E=5wcg%xy)A2e-U zmXA|b`6#wm%SQ&Q3}mGgl?iYoU2@!Rw*`t~* z;C+%{Rbko@)~B&rSe7}jNUR|k_@U=Q)v3&+dBU>LriCRcTU9OWL)=1>xmxIj#vSG+ zq|G*eA=wb~4GkCOpoulaiI$~_bz+IpBPLswYwQr;VXInTp9H-Gt}S$4*Y7esR$!as zLT5hREnTVH;S=tn^dNSRF5$du^@Cf`l}70^3HLuR@g!L*exqs&S>TRe8ZcwxHF&?F z!e0Max+~eMhLUVNl)F#?xyL59i++UteG2q&>~OR%C7*68qS=@Y&6mYZPxfP*^Fh3z z=IPnI#DjO;zYh3!eHERz*LPjd4ZJ%y@Nayt#&O{q*R+)MEf?TNv`!G!H9^d`6oEhZ F{s)mN`VjyC literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-CacheTime-cacheExpiry.serialized b/tests/phpunit/data/ParserCache/1.38-CacheTime-cacheExpiry.serialized new file mode 100644 index 0000000000000000000000000000000000000000..d614788e543e43c393f154e6d41fd6739caeac73 GIT binary patch literal 139 zcmeabvb0iiPE5{74av++RkAX%sxG!NGO$u&&|=69NGvK&4J}Sh@h>RJ%+D)UvQD%z zu&S;twlXw^s6gnnE(S^|DFG=%QzSXpih|6dN+s(|D?RJ%+D)UvQD%z zu&S;twlXw^s6gnnE(S^|DFG=%QzSXpih|6dN+oMQkOa^wkg;G*L8)b##Xv(nQRJ%+D)UvQD%z zu&S;twlXw^s6gnn1`3*3DH$0U7#f%uS{j%bnHm`?fkaJ_l)6?FWENE_S^I$`fHs3{ T0hRJ%+D)UvQD%z zu&S;twlXw^s6gnnE(S^|DFG=%QzSXpih|6dN+oMQkOa^wkg;G*L8)b##Xv(nQ$Uin E0Kc0ka{vGU literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-CacheTime-usedOptions.serialized b/tests/phpunit/data/ParserCache/1.38-CacheTime-usedOptions.serialized new file mode 100644 index 0000000000000000000000000000000000000000..8b10a40ba0d1fe8f1e46c55820b22499aabb64be GIT binary patch literal 166 zcmeabvb0iiPE5{74av++RkAX%sxG!NGO$u&&|=69NGvK&4J}Sh@h>RJ%+D)UvQD%z z0x2-DQpztVaa6KSvNE)WaU&qy+F~n1V~Bo)xj;ogGnIgpp(&D_Yehk3QKgc#A4me| V5Rj!{O+l$;nZ-aWJySrEwE*>ZF!%rf literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-binaryPageProperties.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-binaryPageProperties.serialized new file mode 100644 index 0000000000000000000000000000000000000000..b16b3da4b695a923ae6e53672e7b8d30bc4abb61 GIT binary patch literal 1934 zcmai#O>fgc5Qc-eP!I=x0mzpk4kd|80OtfrN?fH$RHyX9Wol28CF>8ZH)%@MBPV`Y zL5RP^Y`(hnxR8q@@1xn7_njFJyjtCJhM;m(gPG1|+VS=q-c|0^-g{2PKB&YaTxh46 zdsWXdkNP`C^dK3}V2nMHOmn9RgkD_}`G%1#&^S(&z<*k%v6vpE zSty{G*4uI-$S@Qjt^7-F#5j{wgPm7{g&VCYKeD+RFaNyWeY~@?v-e{6r~jbx{n_EuCv@&K&FFHuM}t;(bkwu1taIl^ zBF0=pOqcfQ+L8^>N#IQ4U~uAZ8-R;U^N)*RDn)3Qcu&J8IkjdRG~D{;mMwu;=wr-M zr3)-CwI{ahVNjrX%|nHAOmvH~oqmOIO0I88E6IaKR6!6bk?BB%mh&#(4@^2X5Qh0JKK5iALK|^v4HRbpGcjq-8+!vP^2f+BA(P2}uLKx`*KJP><7f8c zeRo$8^L*y4KvpQDT9vhO*kH&$D(2lYr)PiYWotYrXH+r$C4gj$Yo4L`?|&oc9P&*K z8=UieS2-hKF8lb@uWa= zmzZ!6R{b3rF)M}c!LDma!mZC#nA)62xG>YASx8^I)2e;S1;z+6*+!+}MQ+g@MobP0 zWe%d>UL+S9P22Utrv5%1I;Q>Wz7;-3bN7}Esc>h+a!k4nUJRll=>5dQ zst`QUHeU15%U}jFuk`4QLBUnme%F#_Ts>l0NY!F#t8;!~AL15GdtOQ0W3B>S?d~@u zJMBu-T1OqaVhM2~d8uNVSkCn6{vO#ezCtZpaL0z60-H&^jq6h_rULB2>BwwuRjm&Z z-{T|h!}MflpV(Plxs|>(Vfs|zUtz5iH(p(a#Dd8TG_YafEqFhm!v64F2es^3LaC>C z%=dwSsw50MyLSivo$r~!^^9N*+GOI)Ge_?DBsSl)$VX|6(wq(a(dQp<&2QuY literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-empty.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-empty.serialized new file mode 100644 index 0000000000000000000000000000000000000000..8513ec380f9d52f4653c5bfb037b39a959536b01 GIT binary patch literal 1838 zcmai#PjlKZ5XJc{KK2yjl(y!S8Ys>HW@4u~Z|n`I$g)S037Jg3dnNuwc%9_L!M|DU zzV~)XLcbq+OOOg>(&)O;UU)qSUsdS;3ca5Dp;upgg)=5L z${T_~U*8P*osbb|Tvd|c=U6NXmV>UOi(Qjy8Pgow?U^=P1GL-v(M_Z^<_x&gf5(eh z*4)hC_B9~ovLh82F6R?2E{$jo5*Sljy-yg&6hY?eq}Hqw4&7nIc&AYc;O&X2sj)ER zGuyB>N5rP9o+qT#N5 zeQNB1N%hND;H`=(@x)et%}zK8pxz$VWm;7iNe_r|45O#C2mpZ$aK5;2l>XhavH6p57V)PG?%Q_ zsmvW`0=mC@c7#vR@D|*$A&0^?iI;WzREr4*H#i+H+gsI`L&UathugR~*clKz)jPK| zw~0D$ z2XBkxUCr#VD8hI#v5~cMee0F`|0w%7xr@HtGebm>uhGupMAWwmoxYt)+fCU2@0~sv LN%uk=bbb2|M*L_K literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-extensionData.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-extensionData.serialized new file mode 100644 index 0000000000000000000000000000000000000000..94ff801c60a8195a9ba2a19319d0a51befd23a97 GIT binary patch literal 1980 zcmai#!BX2m42F3YAA7vs?E6gM)ul|9I zSX7Gc;MaA*!Y%hylKWi9xTGM_JS3u~^lHDB3R47=Joc> zFW-nawqsKJ@;~sV9_#W^u7A@^cn;vb?Z#!I^#`X%tZ@%uN?ES`U>w@(>O)-rh0zrn z`*CKt9LxE5vb>%8lggD{$^vT(MHR#|*GQi2s)Uuo`TRaPHi(Nr^NG8KRx+bDezqB$ zAD}>fjAw{4RWmBxs1hEunqwb&D8dA_DpyT%+R5KU@lo>=M zUL{#lig5po=CkTH+jnT!v4n8Xn1}d7VOSv5@sB3?T3^e!_c0Y2U^}EHZT_xS>%0)7}CS$g8 ueK{%GFQ!Y*wsh#Go`^AIPw4LA4NT}1I-DIsySZ$?!iNKrv=yS$_3bau?vnBV literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-pageProperties.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-pageProperties.serialized new file mode 100644 index 0000000000000000000000000000000000000000..a366dc347a06fbda38e91f33b8c889a5a785912e GIT binary patch literal 1993 zcmai#O;g)I42JnFKK6uTO54qe258KLB!fdaE4B#Rtk<61bqK@o->Y>#SS-^XJRZkS zw31%w^-RPA5zWC^G_%Iljf=$Dxp=iA{vo21@Wn~Fz^#jhR-B5+-v-|qF#)}5V1*N@ z*ESjgp|5X5er4nc9Ih%O@!wdg3z>tfOo*MaXbb5ScGIIYI|X#p`qocmHRcjjkblpK zSk{Va2=h8;;TC%;EkZ74Tv}4o0wf_(I=Npw@_HH3Ko=ccOB zxc$zwTS|p4t4blXlEfqlHBmQ;hIdL2l(lZkC7Ng`#o1u@i*<(b@f%F9-yi5aFa}5t z5Q%t|B(N0m{uPv9&E_u@DAEk76 zSXah%SYGNx9@(3$L-U&F1~;hPh_YS(fqdNxwA-XYgK`m_?vFq#GUwea= A(EtDd literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-text.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-text.serialized new file mode 100644 index 0000000000000000000000000000000000000000..7f50d41dbea033b45b66b8a88d589660564a1a95 GIT binary patch literal 1850 zcmai#O>^2X5Qh0F9UptbkkVG1S_8!yf|=N9&Kr9JDzfa6WkM#C{~if22(R0om_g6% z$NTQCBjyj7w*pn6ifUcf+G95(_Es_fJM(((LoZKouf4H(@|m|N6y~48vZ{0Y*WeqW z7a-R)tZ~8Rw(`cn`t0r9kY5NHfW~#9IQ|<8WyVv`g>tbQ5-s6cU{h+Jd57}MZ>yPh zSzo(}xWtr$aO&^Kh2{a30eQR(ZQp>iZqFi-9lb_beOpvopZ$4Wz9dgG-vl4hGqcoG;z58>G$ zDuUTh+^-73Q)A;LAH58AAZ2AnX95~7x(>URH0Syr%R=cEOIuy=GkY7iXxj5i;SQw^ zOtsrTkZz4DO=}%>n2Hs|sp6%MRq8l1r2BhdC-@AtXu%yDatv%I@jC8+YB3Yw4o*jA zd#h@5i1-fgaTjJsJBP&1>cXwetqHS-3jYclow)VtJR}ZGW}tyB6K}x(2^9`Ur#h%* zj|xgN#S^{@1XPu~wjEdR4)#AXFb8jk(|yV9vB+4soY|4Ja((XQhwqh5PVS;__skFh fq#LxoI3wy?g_^e}wB3ZmH?Vmyk{*OO>iYfxrx^2X5Qh0JKK6tmrL8!n28uI)nb>K1-PjvYkv~S337Jg(dnFqa;dR>+c>H*G z^}f5SfVm^)Y(bVNgGv>Za@fs;y_L-U#+-ruVvt67QqHtwpP4hO()88*AAKd*3bI`V zJ6!SXP&!j!L-zKrN&Q(Tpa%+fx#ak7%+C@YgUY3i-H>PzR|4A_hs>$V)4!dh-Lk&) z6Jdcd2VvFUlM&NG=rh=LO-Q)tO!dD4u5)-DAZ3 zq)=ucx+kX2`k5wQ_e&WgLX1svXZpm3rUhucB~P#iqzZ2GA0Pxu-Am_SlvyGq zzQWW#ER|-RCzY_}8&P8$CRDHg1Mf;N&z|}2rydNe1E{yn%q;W#s?*2BxJQr~&vte& z3Y~SeA*%mY<^@W1Ju_5}DDalidSzyy9R;dv#8WI4q=hrx7$a%6c?M4cgW$ox7(_+T z^NFWzE_ht8gf<`D45lHoQn$_w6nyA9?iWW|3yRbvkGjAmxF;kwd z_V63xgLb7oT2CFiVhLd^d7(lXTh5H>{MPIYpP>>RxMxC|z@`(g zs?v*yAMqZKe$v=ECU%w|+*a=zKY1weudvpM8?P=+V!@;bTG%k*9^CIx;&^hdgIe|| zq0n7C<3~?GS=wXUv-Q?+x=lbYyd%y}1vkqgVg6=eTGq(*X^_?zl}T>x#gVzjbOYpt xx-}NNnr|L|HIMpIa?KR#?>&h3XijPkjBE63-?fR&oYYri`$7v|%hag;{s;1Ba;X3S literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadata.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadata.serialized new file mode 100644 index 0000000000000000000000000000000000000000..3fa8a1dc50bd4bd0188ae68cd92a8e394a560bd2 GIT binary patch literal 2744 zcmbVOO>f&c5Y2DVaSyE}x#^ldZJlJ}BC(Cy-5w1_W^Jyi50JFuAjp638&Z-TQ3V!z z2oeov9%tUX8D`GnghdOkjnMOhtqwL~!)x|xSUh6U)#brez7i)JjSU;Hh<+u11|AQ* z*dF*+Jjh~iqA_O)dzEYe=T9tBFvihXviSU+MB_Ig;k0wtgj=yKwG<7EVMr+R))$0% zm%6bfyh;T+-5>3prlhq<2K#=Hyo;okiby~X_`YS4Txd5%30j~F*P!UHajtQQi-MD zI@`@FE6buc-099RFkoel7NWKIJ05*b<2V^5aheWBWQEb}xa$|{2QhZ-zg@ziyl+od z=z^=ZlU_(jd}nQC*vF5A@uAdPuTLr)z?~AN1yG*lUcQF`iYUlj&kd4x3ay=MRyx*t z5L~|D5Y5E%Qe;F^G=6ep*OSh@+=w2>P(HKrZ?2TkF9b$2-6OGk!8cPY@^f3L34H4~ zrh0a8SW9@oLiB_kek?Z!)yl$e4~RZ@<~k}I0w1-sFWt~MZDQAkPJfH=)lACbr`-O7 zWk@Y>y+!tW@#3;af80i>0r1)BtKXmZW$9NR;wky}J8*|n0MPQ{5d5oQDCMavmEdiU zaA$E)808r_#x=zue-fI4FiOs1td<2d*7<+{xYiu~;VkvH(?$L#!EgG(8o^+J6JE7d z;uBR89w3^v_vS=}qfVJWxGr$}nIp`}v$xfiQD4KjT8S>MeHIXFyh7_(!_Fp%o1j8n zFLYT6ZR^LO-glvrR`bdI>hXc<0;nysoy`^Q=~eCuo5EP0gB8CnlEEMz4CB#Yn0!in zRG7(a!Jm|v&%aOG2@8dR$48tNrIMNB7#*+NhX+M!9foPm6b4g!!!4&K`3lp%CncBm zo2W`{8(+VYaEFpOTWfc??iX>-etn=QkN9=@zc9navC!fu3OfM-`+s@1ciQzUq^BlS zulX|5va(B^Il0vJhcAfpy%9h8L3Nya7M%yC9q=Bv=c&F^{6gTg!k`V`VVa&W5qf?P zcw6OBd=tm%rk&O_(2O~|F7WHg((4*J z9FHHGR~Vxkd7LP2j9^2n42JVteC#QKo-lBo_z4L zTIqcy?L6{>$XkHYsODQ!ZH*W8uA)~R`TfYdaDQCnOFS5Fprgykv!CDxBc@QSwy?sf zC^p&~0HLpMM1E)F5DczLCGcx3E;5mVDV2-$ShS@u65HufnymubXEz#W zBj%N)8r;0DSh(c}6=yEzGcL|aGzSUElveIHLSllT()GMDqAVP`!-(<0pejJNE9R!g z1(AEP5p9%vHp6{_slD7AJVlqb1$exP$gl(C3eL*kASJ378_c)CI5R=WVuQI`ESKi4 z%(l{%FW|;DOk!UC2j1#oSv-r?ADRiL1Gu-%xJ=6OtkXkg+#{$$6e~9vhdy+5A+G;I zl@%&;J~Ld7<$O3<-c8*}<;pHaj@m$8d4rkNp5Hbu;7Q_q{t%zs<|5F1;$cxrk&=yH zZ3f$rg{IaSfq_q5!>%FCg}KM7RHnu9Qm5j?-X<-Y*St`;!@>+H+s!{nH{{B(w2nL| zV+Bd7L}e0{I?jZAertAw&#;v(xMM<^z_t_5;|5%d8wqaXblhxr)s_~K*x^0y;;gYV zWOnLLZb7>y&K@)pETUe}3&=Tsg2WQmuv4crC+KA$W&Qqj==(uG@Wb%3Z>t?$B`e7otKD}>{W_{2r)3G$~ z;P5j8+Lt>VA1YyYO%}zo8_J2Ti)eEfF|Z3n4- OHjh8Zky^sWmbZ7Rt$Gyz literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadataPost1_34.serialized b/tests/phpunit/data/ParserCache/1.38-ParserOutput-withMetadataPost1_34.serialized new file mode 100644 index 0000000000000000000000000000000000000000..f950092112d747b3e536e2442078dc57fb471af4 GIT binary patch literal 1908 zcmai#OLy8Z5QX_IUUn7Zl(uG-@+i*Xbz-MkPwWY($d4llLQYQpdq*}9#p9+c7WyR5 z+Nu)}S=1)!tNl-Vh` zRK2|!cta8TL)%YB1(;WodUER=u;-H#6=g2xGcL+WL2_5aQ5Fu} zVa()cP!%BC3UHI7g2-pF6K#}xxWwleQ~Pmm_!wT%JM_<17_Rb2T-yY)=>?OZWi!^JFn)@AN z)O_8>m3^FC(DvYTmn%4x;Kr?^I=k`qw7$dv@9+?1O$Y)O0{zadX+uTXy~cmSq^__I zU!vu}EIDV`GVvDtpP(@qoa*34KPadu`(tq!NzmFI_Ksb-fa6UDv?dQYIab21m@JHz zQyX+E*Oy*i|I^uzvu*0z=_FzV=@xA-POyEe(E05Aw4I;&-}8JxlGZ{ry1xAdxmbL` literal 0 HcmV?d00001 diff --git a/tests/phpunit/includes/libs/serialization/SerializationTestUtils.php b/tests/phpunit/includes/libs/serialization/SerializationTestUtils.php index b67f37e4927..5e31d5b4843 100644 --- a/tests/phpunit/includes/libs/serialization/SerializationTestUtils.php +++ b/tests/phpunit/includes/libs/serialization/SerializationTestUtils.php @@ -215,12 +215,14 @@ class SerializationTestUtils { sort( $savedFiles ); $path = $savedFiles[count( $savedFiles ) - 1]; } + $curPath = "$this->serializedDataPath/{$this->getCurrentVersion()}-$class-$testCaseName.$this->ext"; return (object)[ 'version' => $version, 'class' => $class, 'testCaseName' => $testCaseName, 'ext' => $this->ext, 'path' => $path, + 'currentVersionPath' => $curPath, 'data' => file_exists( $path ) ? file_get_contents( $path ) : null, ]; } diff --git a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php index 5802ed7e058..56beef56a49 100644 --- a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php +++ b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php @@ -55,6 +55,8 @@ abstract class ParserCacheSerializationTestCases { . '\xca\x49\x01\x00\x85\x11\x4a\x0d\x0b\x00\x00\x00", ]; + private const CACHE_TIME = '20010419042521'; + /** * Get acceptance test cases for CacheTime class. * @see SerializationTestTrait::getTestInstancesAndAssertions() @@ -64,9 +66,8 @@ abstract class ParserCacheSerializationTestCases { $cacheTimeWithUsedOptions = new CacheTime(); $cacheTimeWithUsedOptions->recordOptions( [ 'optA', 'optX' ] ); - $cacheTimestamp = MWTimestamp::convert( TS_MW, 987654321 ); $cacheTimeWithTime = new CacheTime(); - $cacheTimeWithTime->setCacheTime( $cacheTimestamp ); + $cacheTimeWithTime->setCacheTime( self::CACHE_TIME ); $cacheExpiry = 10; $cacheTimeWithExpiry = new CacheTime(); @@ -106,8 +107,8 @@ abstract class ParserCacheSerializationTestCases { 'instance' => $cacheTimeWithTime, 'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, CacheTime $object - ) use ( $cacheTimestamp ) { - $testCase->assertSame( $cacheTimestamp, $object->getCacheTime() ); + ) { + $testCase->assertSame( self::CACHE_TIME, $object->getCacheTime() ); } ], 'cacheExpiry' => [ @@ -135,6 +136,11 @@ abstract class ParserCacheSerializationTestCases { * @return array[] */ public static function getParserOutputTestCases() { + $parserOutputWithCacheTimeProps = new ParserOutput( 'CacheTime' ); + $parserOutputWithCacheTimeProps->setCacheTime( self::CACHE_TIME ); + $parserOutputWithCacheTimeProps->updateCacheExpiry( 10 ); + $parserOutputWithCacheTimeProps->setCacheRevisionId( 42 ); + $parserOutputWithUsedOptions = new ParserOutput( 'Dummy' ); $parserOutputWithUsedOptions->recordOption( 'optA' ); $parserOutputWithUsedOptions->recordOption( 'optX' ); @@ -265,6 +271,14 @@ abstract class ParserCacheSerializationTestCases { $testCase->assertNull( $object->getTimeSinceStart( 'wall' ) ); } ], + 'cacheTime' => [ + 'instance' => $parserOutputWithCacheTimeProps, + 'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) { + $testCase->assertSame( self::CACHE_TIME, $object->getCacheTime() ); + $testCase->assertSame( 10, $object->getCacheExpiry() ); + $testCase->assertSame( 42, $object->getCacheRevisionId() ); + } + ], 'text' => [ 'instance' => new ParserOutput( 'Lorem Ipsum' ), 'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) { diff --git a/tests/phpunit/includes/parser/validateParserCacheSerializationTestData.php b/tests/phpunit/includes/parser/validateParserCacheSerializationTestData.php index 2b5e6bccb35..4b809a48299 100644 --- a/tests/phpunit/includes/parser/validateParserCacheSerializationTestData.php +++ b/tests/phpunit/includes/parser/validateParserCacheSerializationTestData.php @@ -84,8 +84,8 @@ class ValidateParserCacheSerializationTestData extends Maintenance { } else { if ( $data !== $fileInfo->data ) { if ( $this->hasOption( 'update' ) ) { - $this->output( 'Data mismatch, updating file: ' . $fileInfo->path . "\n" ); - file_put_contents( $fileInfo->path, $data ); + $this->output( 'Data mismatch, updating file: ' . $fileInfo->currentVersionPath . "\n" ); + file_put_contents( $fileInfo->currentVersionPath, $data ); } else { $this->fatalError( "Serialization data mismatch: {$fileInfo->path}. " . "If this was expected, rerun the script with the --update option "