Remove parser cache splitting ('dtreply' option)

Bug: T280599
Change-Id: I08b52874d575619308b5b83a39acfb6353c5b7b5
This commit is contained in:
Bartosz Dziewoński 2021-08-25 11:35:38 +02:00
parent e3af0bc65b
commit dbb8b00ec7
2 changed files with 1 additions and 52 deletions

View file

@ -403,10 +403,8 @@
"EchoGetBundleRules": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onEchoGetBundleRules",
"EchoGetEventsForRevision": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks\\EchoHooks::onEchoGetEventsForRevision",
"LoadExtensionSchemaUpdates": "installer",
"ArticleParserOptions": "parser",
"ParserAfterParse": "parser",
"ParserAfterTidy": "parser",
"ParserOptionsRegister": "parser",
"BeforeDisplayNoArticleText": "page",
"BeforePageDisplay": "page",
"GetActionName": "page",

View file

@ -9,22 +9,16 @@
namespace MediaWiki\Extension\DiscussionTools\Hooks;
use Article;
use ConfigFactory;
use MediaWiki\Extension\DiscussionTools\CommentFormatter;
use MediaWiki\Hook\ParserAfterParseHook;
use MediaWiki\Hook\ParserAfterTidyHook;
use MediaWiki\Hook\ParserOptionsRegisterHook;
use MediaWiki\Page\Hook\ArticleParserOptionsHook;
use Parser;
use ParserOptions;
use StripState;
class ParserHooks implements
ParserAfterParseHook,
ParserAfterTidyHook,
ArticleParserOptionsHook,
ParserOptionsRegisterHook
ParserAfterTidyHook
{
/** @var ConfigFactory */
private $configFactory;
@ -95,47 +89,4 @@ class ParserHooks implements
] );
}
}
/**
* @param Article $article Article about to be parsed
* @param ParserOptions $popts Mutable parser options
* @return bool|void True or no return value to continue or false to abort
*/
public function onArticleParserOptions( Article $article, ParserOptions $popts ) {
$dtConfig = $this->configFactory->makeConfig( 'discussiontools' );
if (
!$dtConfig->get( 'DiscussionToolsUseParserCache' ) ||
!HookUtils::isAvailableForTitle( $article->getTitle() )
) {
return;
}
foreach ( CommentFormatter::USE_WITH_FEATURES as $feature ) {
if (
// If the feature is enabled by default, always apply the DOM transform
$dtConfig->get( 'DiscussionTools_' . $feature ) === 'available' ||
// ...or if has been enabled by the user
HookUtils::isFeatureEnabledForUser( $popts->getUserIdentity(), $feature )
) {
// For backwards-compatibility until the canonical cache entries
// without DiscussionTools DOM transform expire (T280599)
$popts->setOption( 'dtreply', true );
return;
}
}
}
/**
* Register additional parser options
*
* @param array &$defaults
* @param array &$inCacheKey
* @param array &$lazyLoad
* @return bool|void
*/
public function onParserOptionsRegister( &$defaults, &$inCacheKey, &$lazyLoad ) {
$defaults['dtreply'] = null;
$inCacheKey['dtreply'] = true;
}
}