aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Storage/PageEditStash.php
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@cscott.net>2021-10-08 16:04:37 -0400
committerC. Scott Ananian <cscott@cscott.net>2021-10-15 14:25:54 -0400
commit06ab90f163fd63f0cda8952ecf4d6e15a6e16260 (patch)
tree4c0651bfa3509fd46bc347965a6494b4e899ba87 /includes/Storage/PageEditStash.php
parent8979eb0c57e0817a372a0b06e5f03a17a709cd54 (diff)
downloadmediawikicore-06ab90f163fd63f0cda8952ecf4d6e15a6e16260.tar.gz
mediawikicore-06ab90f163fd63f0cda8952ecf4d6e15a6e16260.zip
Add new ParserOutput::{get,set}OutputFlag() interface
This is a uniform mechanism to access a number of bespoke boolean flags in ParserOutput. It allows extensibility in core (by adding new field names to ParserOutputFlags) without exposing new getter/setter methods to Parsoid. It replaces the ParserOutput::{get,set}Flag() interface which (a) doesn't allow access to certain flags, and (b) is typically called with a string rather than a constant, and (c) has a very generic name. (Note that Parser::setOutputFlag() already called these "output flags".) In the future we might unify the representation so that we store everything in $mFlags and don't have explicit properties in ParserOutput, but those representation details should be invisible to the clients of this API. (We might also use a proper enumeration for ParserOutputFlags, when PHP supports this.) There is some overlap with ParserOutput::{get,set}ExtensionData(), but I've left those methods as-is because (a) they allow for non-boolean data, unlike the *Flag() methods, and (b) it seems worthwhile to distingush properties set by extensions from properties used by core. Code search: https://codesearch.wmcloud.org/search/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3E%28g%7Cs%29etFlag%5C%28&i=nope&files=&excludeFiles=&repos= Bug: T292868 Change-Id: I39bc58d207836df6f328c54be9e3330719cebbeb
Diffstat (limited to 'includes/Storage/PageEditStash.php')
-rw-r--r--includes/Storage/PageEditStash.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/includes/Storage/PageEditStash.php b/includes/Storage/PageEditStash.php
index b1a3fdc2b409..8645cd706ee4 100644
--- a/includes/Storage/PageEditStash.php
+++ b/includes/Storage/PageEditStash.php
@@ -28,6 +28,7 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Page\PageIdentity;
+use MediaWiki\Parser\ParserOutputFlags;
use MediaWiki\Storage\Hook\ParserOutputStashForEditHook;
use MediaWiki\User\UserEditTracker;
use MediaWiki\User\UserFactory;
@@ -286,7 +287,7 @@ class PageEditStash {
return false;
}
- if ( $editInfo->output->getFlag( 'vary-revision' ) ) {
+ if ( $editInfo->output->getOutputFlag( ParserOutputFlags::VARY_REVISION ) ) {
// This can be used for the initial parse, e.g. for filters or doUserEditContent(),
// but a second parse will be triggered in doEditUpdates() no matter what
$logger->info(
@@ -296,16 +297,16 @@ class PageEditStash {
} else {
static $flagsMaybeReparse = [
// Similar to the above if we didn't guess the ID correctly
- 'vary-revision-id',
+ ParserOutputFlags::VARY_REVISION_ID,
// Similar to the above if we didn't guess the timestamp correctly
- 'vary-revision-timestamp',
+ ParserOutputFlags::VARY_REVISION_TIMESTAMP,
// Similar to the above if we didn't guess the content correctly
- 'vary-revision-sha1',
+ ParserOutputFlags::VARY_REVISION_SHA1,
// Similar to the above if we didn't guess page ID correctly
- 'vary-page-id'
+ ParserOutputFlags::VARY_PAGE_ID,
];
foreach ( $flagsMaybeReparse as $flag ) {
- if ( $editInfo->output->getFlag( $flag ) ) {
+ if ( $editInfo->output->getOutputFlag( $flag ) ) {
$logger->debug(
"Cache for key '{key}' has $flag; post-insertion parse possible.",
$logContext
@@ -470,7 +471,7 @@ class PageEditStash {
$age = time() - (int)wfTimestamp( TS_UNIX, $parserOutput->getCacheTime() );
$ttl = min( $parserOutput->getCacheExpiry() - $age, self::MAX_CACHE_TTL );
// Avoid extremely stale user signature timestamps (T84843)
- if ( $parserOutput->getFlag( 'user-signature' ) ) {
+ if ( $parserOutput->getOutputFlag( ParserOutputFlags::USER_SIGNATURE ) ) {
$ttl = min( $ttl, self::MAX_SIGNATURE_TTL );
}