Merge CacheTime and ParserOutput accessedOptions properties

Change-Id: I5785596d68e8923f8bcbd182ace0b1991bd75c9a
This commit is contained in:
Petr Pchelko 2020-11-05 10:05:40 -07:00
parent 021a1f82d2
commit b956c77d27
48 changed files with 83 additions and 90 deletions

View file

@ -37,9 +37,10 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
use JsonUnserializableTrait;
/**
* @var string[] ParserOptions which have been taken into account to produce output.
* @var true[] ParserOptions which have been taken into account
* to produce output, option names stored in array keys.
*/
public $mUsedOptions;
protected $mParseUsedOptions = [];
/**
* @var string|null Compatibility check
@ -214,7 +215,36 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
* @return string[]
*/
public function getUsedOptions(): array {
return $this->mUsedOptions;
return array_keys( $this->mParseUsedOptions );
}
/**
* Tags a parser option for use in the cache key for this parser output.
* Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState().
* The information gathered here is available via getUsedOptions(),
* and is used by ParserCache::save().
*
* @see ParserCache::getMetadata
* @see ParserCache::save
* @see ParserOptions::addExtraKey
* @see ParserOptions::optionsHash
* @param string $option
*/
public function recordOption( string $option ) {
$this->mParseUsedOptions[$option] = true;
}
/**
* Tags a list of parser option names for use in the cache key for this parser output.
*
* @see recordOption()
* @param string[] $options
*/
public function recordOptions( array $options ) {
$this->mParseUsedOptions = array_merge(
$this->mParseUsedOptions,
array_fill_keys( $options, true )
);
}
/**
@ -225,7 +255,7 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
*/
protected function toJsonArray(): array {
return [
'UsedOptions' => $this->mUsedOptions,
'ParseUsedOptions' => $this->mParseUsedOptions,
'CacheExpiry' => $this->mCacheExpiry,
'CacheTime' => $this->mCacheTime,
'CacheRevisionId' => $this->mCacheRevisionId,
@ -245,11 +275,14 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
* @param array $jsonData
*/
protected function initFromJson( JsonUnserializer $unserializer, array $jsonData ) {
if ( array_key_exists( 'ParseUsedOptions', $jsonData ) ) {
// Forward compatibility
$this->mUsedOptions = array_keys( $jsonData['ParseUsedOptions'] ?: [] );
if ( array_key_exists( 'AccessedOptions', $jsonData ) ) {
// Backwards compatibility for ParserOutput
$this->mParseUsedOptions = $jsonData['AccessedOptions'] ?: [];
} elseif ( array_key_exists( 'UsedOptions', $jsonData ) ) {
// Backwards compatibility
$this->recordOptions( $jsonData['UsedOptions'] ?: [] );
} else {
$this->mUsedOptions = $jsonData['UsedOptions'];
$this->mParseUsedOptions = $jsonData['ParseUsedOptions'] ?: [];
}
$this->mCacheExpiry = $jsonData['CacheExpiry'];
$this->mCacheTime = $jsonData['CacheTime'];
@ -258,9 +291,10 @@ class CacheTime implements ParserCacheMetadata, JsonUnserializable {
}
public function __wakeup() {
$forwardCompatOptions = $this->getGhostFieldValue( 'mParseUsedOptions' );
if ( $forwardCompatOptions ) {
$this->mUsedOptions = array_keys( $forwardCompatOptions );
// Backwards compatibility, pre 1.36
$priorOptions = $this->getGhostFieldValue( 'mUsedOptions' );
if ( $priorOptions ) {
$this->recordOptions( $priorOptions );
}
}
}

View file

@ -310,18 +310,6 @@ class ParserCache {
return null;
}
// HACK: The property 'mUsedOptions' was made private in the initial
// deployment of mediawiki 1.36.0-wmf.11. Thus anything it stored is
// broken and incompatible with wmf.10. We can't use RejectParserCacheValue
// because that hook does not run until later.
// See https://phabricator.wikimedia.org/T264257
if ( !isset( $metadata->mUsedOptions ) ) {
$this->logger->debug( 'Bad ParserOutput key from wmf.11 T264257', [
'name' => $this->name
] );
return null;
}
$this->logger->debug( 'Parser cache options found', [
'name' => $this->name
] );
@ -497,7 +485,7 @@ class ParserCache {
}
$metadata = new CacheTime;
$metadata->mUsedOptions = $parserOutput->getUsedOptions();
$metadata->recordOptions( $parserOutput->getUsedOptions() );
$metadata->updateCacheExpiry( $expire );
$metadata->setCacheTime( $cacheTime );

View file

@ -193,11 +193,6 @@ class ParserOutput extends CacheTime {
*/
private $mIndexPolicy = '';
/**
* @var true[] List of ParserOptions (stored in the keys).
*/
private $mAccessedOptions = [];
/**
* @var array extra data used by extensions.
*/
@ -1182,35 +1177,6 @@ class ParserOutput extends CacheTime {
return $this->mProperties;
}
/**
* Returns the options from its ParserOptions which have been taken
* into account to produce this output.
* @return string[]
*/
public function getUsedOptions() : array {
// TODO: Merge mAccessedOptions with CacheTime::mUsedOptions
if ( !isset( $this->mAccessedOptions ) ) {
return [];
}
return array_keys( $this->mAccessedOptions );
}
/**
* Tags a parser option for use in the cache key for this parser output.
* Registered as a watcher at ParserOptions::registerWatcher() by Parser::clearState().
* The information gathered here is available via getUsedOptions(),
* and is used by ParserCache::save().
*
* @see ParserCache::getMetadata
* @see ParserCache::save
* @see ParserOptions::addExtraKey
* @see ParserOptions::optionsHash
* @param string $option
*/
public function recordOption( $option ) {
$this->mAccessedOptions[$option] = true;
}
/**
* Attaches arbitrary data to this ParserObject. This can be used to store some information in
* the ParserOutput object for later use during page output. The data will be cached along with
@ -1500,7 +1466,7 @@ class ParserOutput extends CacheTime {
);
$this->mFlags = self::mergeMap( $this->mFlags, $source->mFlags );
$this->mAccessedOptions = self::mergeMap( $this->mAccessedOptions, $source->mAccessedOptions );
$this->mParseUsedOptions = self::mergeMap( $this->mParseUsedOptions, $source->mParseUsedOptions );
// TODO: maintain per-slot limit reports!
if ( empty( $this->mLimitReportData ) ) {
@ -1723,7 +1689,6 @@ class ParserOutput extends CacheTime {
'Timestamp' => $this->mTimestamp,
'EnableOOUI' => $this->mEnableOOUI,
'IndexPolicy' => $this->mIndexPolicy,
'AccessedOptions' => $this->mAccessedOptions,
// may contain arbitrary structures!
'ExtensionData' => $this->mExtensionData,
'LimitReportData' => $this->mLimitReportData,
@ -1767,7 +1732,6 @@ class ParserOutput extends CacheTime {
*/
protected function initFromJson( JsonUnserializer $unserializer, array $jsonData ) {
parent::initFromJson( $unserializer, $jsonData );
$this->mUsedOptions = null;
$this->mText = $jsonData['Text'];
$this->mLanguageLinks = $jsonData['LanguageLinks'];
@ -1797,13 +1761,8 @@ class ParserOutput extends CacheTime {
$this->mTimestamp = $jsonData['Timestamp'];
$this->mEnableOOUI = $jsonData['EnableOOUI'];
$this->mIndexPolicy = $jsonData['IndexPolicy'];
if ( array_key_exists( 'ParseUsedOptions', $jsonData ) ) {
// Forward compatibility
$this->mAccessedOptions = $jsonData['ParseUsedOptions'];
} else {
$this->mAccessedOptions = $jsonData['AccessedOptions'];
}
$this->mExtensionData = $unserializer->unserializeArray( $jsonData['ExtensionData'] ?? [] );
$this->mExtensionData = $jsonData['ExtensionData'];
$this->mLimitReportData = $jsonData['LimitReportData'];
$this->mLimitReportJSData = $jsonData['LimitReportJSData'];
$this->mParseStartTime = $jsonData['ParseStartTime'];
@ -1866,10 +1825,10 @@ class ParserOutput extends CacheTime {
}
public function __wakeup() {
$forwardOptions = $this->getGhostFieldValue( 'mParseUsedOptions' );
if ( $forwardOptions ) {
$this->mAccessedOptions = $forwardOptions;
$this->mUsedOptions = null;
// Backwards compatibility, pre 1.36
$priorAccessedOptions = $this->getGhostFieldValue( 'mAccessedOptions' );
if ( $priorAccessedOptions ) {
$this->mParseUsedOptions = $priorAccessedOptions;
}
}
}

View file

@ -1 +1 @@
{"UsedOptions":null,"CacheExpiry":10,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
{"ParseUsedOptions":[],"CacheExpiry":10,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}

View file

@ -1 +1 @@
{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":1234,"Version":"1.6.4","_type_":"CacheTime"}
{"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":1234,"Version":"1.6.4","_type_":"CacheTime"}

View file

@ -1 +1 @@
{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"20010419042521","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
{"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"20010419042521","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}

View file

@ -1 +1 @@
{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
{"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}

View file

@ -1 +1 @@
{"UsedOptions":["optA","optX"],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
{"ParseUsedOptions":{"optA":true,"optX":true},"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}

View file

@ -1 +1 @@
{"Text":"","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":{"empty":"","\\x00":"\u0000","gzip":{"_type_":"string","_encoding_":"base64","_data_":"H4sIAAAAAAAAA8tIzcnJVyjPLycKCQkJLiAnykkBAIURSg0LAAAA"}},"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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","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":{"empty":"","\\x00":"\u0000","gzip":{"_type_":"string","_encoding_":"base64","_data_":"H4sIAAAAAAAAA8tIzcnJVyjPLycKCQkJLiAnykkBAIURSg0LAAAA"}},"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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","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":{"boolean":true,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","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":{"boolean":true,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","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":{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","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":{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"Lorem Ipsum","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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"Lorem Ipsum","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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"Dummy","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":{"optA":true,"optX":true},"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"Dummy","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":{"optA":true,"optX":true},"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","LanguageLinks":["link1","link2"],"Categories":{"category2":1,"category1":2},"Indicators":{"indicator1":"indicator1_value"},"TitleText":"title_text1","Links":{"0":{"Link1":42},"2":{"Link2":43}},"LinksSpecial":[],"Templates":{"10":{"Template1":42}},"TemplateIds":{"10":{"Template1":4242}},"Images":{"Image1":1},"FileSearchOptions":{"Image1":{"time":"19731129213309","sha1":"test_sha1"}},"ExternalLinks":{"https://test.org":1},"InterwikiLinks":{"enwiki":{"interwiki1":1,"interwiki2":1}},"NewSection":true,"HideNewSection":true,"NoGallery":false,"HeadItems":{"tag1":"head_item1"},"Modules":["module1"],"ModuleStyles":["module_style1"],"JsConfigVars":{"key1":"value1"},"OutputHooks":[["hook1",{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}}]],"Warnings":{"warning1":1},"Sections":["section1","section2"],"Properties":[],"TOCHTML":"tochtml1","Timestamp":"20010419042521","EnableOOUI":true,"IndexPolicy":"policy1","AccessedOptions":[],"ExtensionData":[],"LimitReportData":{"limit_report_key1":"value1"},"LimitReportJSData":{"limit_report_key1":"value1"},"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":{"test":true},"SpeculativeRevId":42,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","LanguageLinks":["link1","link2"],"Categories":{"category2":1,"category1":2},"Indicators":{"indicator1":"indicator1_value"},"TitleText":"title_text1","Links":{"0":{"Link1":42},"2":{"Link2":43}},"LinksSpecial":[],"Templates":{"10":{"Template1":42}},"TemplateIds":{"10":{"Template1":4242}},"Images":{"Image1":1},"FileSearchOptions":{"Image1":{"time":"19731129213309","sha1":"test_sha1"}},"ExternalLinks":{"https://test.org":1},"InterwikiLinks":{"enwiki":{"interwiki1":1,"interwiki2":1}},"NewSection":true,"HideNewSection":true,"NoGallery":false,"HeadItems":{"tag1":"head_item1"},"Modules":["module1"],"ModuleStyles":["module_style1"],"JsConfigVars":{"key1":"value1"},"OutputHooks":[["hook1",{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}}]],"Warnings":{"warning1":1},"Sections":["section1","section2"],"Properties":[],"TOCHTML":"tochtml1","Timestamp":"20010419042521","EnableOOUI":true,"IndexPolicy":"policy1","ExtensionData":[],"LimitReportData":{"limit_report_key1":"value1"},"LimitReportJSData":{"limit_report_key1":"value1"},"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":{"test":true},"SpeculativeRevId":42,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":true,"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":4242,"RevisionTimestampUsed":"19731129213309","RevisionUsedSha1Base36":"test_hash","WrapperDivClasses":{"test_wrapper":true},"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":true,"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":4242,"RevisionTimestampUsed":"19731129213309","RevisionUsedSha1Base36":"test_hash","WrapperDivClasses":{"test_wrapper":true},"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +1 @@
{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":{"Link3":1},"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":["script1"],"ExtraDefaultSrcs":["default1"],"ExtraStyleSrcs":["style1"],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":{"Link3":1},"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":["script1"],"ExtraDefaultSrcs":["default1"],"ExtraStyleSrcs":["style1"],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}

View file

@ -1 +0,0 @@
{"_type_":"CacheTime","ParseUsedOptions":{"optA":true,"optX":true},"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -1 +0,0 @@
{"_type_":"ParserOutput","Text":"","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":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -1 +0,0 @@
{"_type_":"ParserOutput","Text":"Dummy","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":{"optA":true,"optX":true},"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -0,0 +1 @@
{"_type_":"CacheTime","UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -0,0 +1 @@
O:9:"CacheTime":5:{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;}

View file

@ -0,0 +1 @@
{"_type_":"CacheTime","UsedOptions":["optA","optX"],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -0,0 +1 @@
O:9:"CacheTime":5:{s:12:"mUsedOptions";a:2:{i:0;s:4:"optA";i:1;s:4:"optX";}s:8:"mVersion";s:5:"1.6.4";s:10:"mCacheTime";s:0:"";s:12:"mCacheExpiry";N;s:16:"mCacheRevisionId";N;}

View file

@ -0,0 +1 @@
{"_type_":"ParserOutput","Text":"","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":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -0,0 +1 @@
{"_type_":"ParserOutput","Text":"Dummy","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":{"optA":true,"optX":true},"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}

View file

@ -5,6 +5,7 @@ namespace MediaWiki\Tests\Parser;
use CacheTime;
use MediaWikiIntegrationTestCase;
use MWTimestamp;
use ParserOptions;
use Wikimedia\Tests\SerializationTestTrait;
/**
@ -118,4 +119,11 @@ class CacheTimeTest extends MediaWikiIntegrationTestCase {
)
);
}
public function testGetSetOptions() {
$options = ParserOptions::allCacheVaryingOptions();
$cacheTime = new CacheTime();
$cacheTime->recordOptions( $options );
$this->assertArrayEquals( $options, $cacheTime->getUsedOptions() );
}
}

View file

@ -62,7 +62,7 @@ abstract class ParserCacheSerializationTestCases {
*/
public static function getCacheTimeTestCases(): array {
$cacheTimeWithUsedOptions = new CacheTime();
$cacheTimeWithUsedOptions->mUsedOptions = [ 'optA', 'optX' ];
$cacheTimeWithUsedOptions->recordOptions( [ 'optA', 'optX' ] );
$cacheTimestamp = MWTimestamp::convert( TS_MW, 987654321 );
$cacheTimeWithTime = new CacheTime();
@ -99,7 +99,7 @@ abstract class ParserCacheSerializationTestCases {
'usedOptions' => [
'instance' => $cacheTimeWithUsedOptions,
'assertions' => function ( MediaWikiIntegrationTestCase $testCase, CacheTime $object ) {
$testCase->assertArrayEquals( [ 'optA', 'optX' ], $object->mUsedOptions );
$testCase->assertArrayEquals( [ 'optA', 'optX' ], $object->getUsedOptions() );
}
],
'cacheTime' => [

View file

@ -6,6 +6,7 @@ use Wikimedia\Tests\SerializationTestTrait;
/**
* @covers ParserOutput
* @covers CacheTime
* @group Database
* ^--- trigger DB shadowing because we are using Title magic
*/