diff --git a/includes/FilterRunner.php b/includes/FilterRunner.php index 1b6055fee..9230ee109 100644 --- a/includes/FilterRunner.php +++ b/includes/FilterRunner.php @@ -176,8 +176,6 @@ class FilterRunner { ); $generator = $this->varGeneratorFactory->newGenerator( $this->vars ); $this->vars = $generator->addGenericVars()->getVariableHolder(); - - $this->vars->forFilter = true; $this->ruleChecker = $this->ruleCheckerFactory->newRuleChecker( $this->vars ); } diff --git a/includes/VariableGenerator/RCVariableGenerator.php b/includes/VariableGenerator/RCVariableGenerator.php index 91ff84dc0..c6beb50de 100644 --- a/includes/VariableGenerator/RCVariableGenerator.php +++ b/includes/VariableGenerator/RCVariableGenerator.php @@ -233,7 +233,8 @@ class RCVariableGenerator extends VariableGenerator { $this->addEditVars( $this->wikiPageFactory->newFromTitle( $title ), - $this->contextUser + $this->contextUser, + false ); return $this; diff --git a/includes/VariableGenerator/VariableGenerator.php b/includes/VariableGenerator/VariableGenerator.php index d91a912ef..826b8bde6 100644 --- a/includes/VariableGenerator/VariableGenerator.php +++ b/includes/VariableGenerator/VariableGenerator.php @@ -174,9 +174,11 @@ class VariableGenerator { /** * @param WikiPage $page * @param UserIdentity $userIdentity The current user + * @param bool $forFilter Whether the variables should be computed for an ongoing action + * being filtered * @return $this For chaining */ - public function addEditVars( WikiPage $page, UserIdentity $userIdentity ): self { + public function addEditVars( WikiPage $page, UserIdentity $userIdentity, bool $forFilter = true ): self { $this->vars->setLazyLoadVar( 'edit_diff', 'diff', [ 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_wikitext' ] ); $this->vars->setLazyLoadVar( 'edit_diff_pst', 'diff', @@ -206,12 +208,14 @@ class VariableGenerator { [ 'text-var' => 'new_wikitext', 'article' => $page, + 'forFilter' => $forFilter, 'contextUserIdentity' => $userIdentity ] ); $this->vars->setLazyLoadVar( 'old_links', 'links-from-wikitext-or-database', [ 'article' => $page, 'text-var' => 'old_wikitext', + 'forFilter' => $forFilter, 'contextUserIdentity' => $userIdentity ] ); $this->vars->setLazyLoadVar( 'new_pst', 'parse-wikitext', diff --git a/includes/Variables/LazyVariableComputer.php b/includes/Variables/LazyVariableComputer.php index 004ede067..295008632 100644 --- a/includes/Variables/LazyVariableComputer.php +++ b/includes/Variables/LazyVariableComputer.php @@ -216,7 +216,7 @@ class LazyVariableComputer { // this inference is ugly, but the name isn't accessible from here // and we only want this for debugging $varName = strpos( $parameters['text-var'], 'old_' ) === 0 ? 'old_links' : 'all_links'; - if ( $vars->forFilter ) { + if ( $parameters['forFilter'] ?? false ) { $this->logger->debug( "Loading $varName from DB" ); $links = $this->getLinksFromDB( $article ); } elseif ( $article->getContentModel() === CONTENT_MODEL_WIKITEXT ) { diff --git a/includes/Variables/VariableHolder.php b/includes/Variables/VariableHolder.php index 53028cae4..41b0684ea 100644 --- a/includes/Variables/VariableHolder.php +++ b/includes/Variables/VariableHolder.php @@ -13,9 +13,6 @@ class VariableHolder { */ private $mVars = []; - /** @var bool Whether this object is being used for an ongoing action being filtered */ - public $forFilter = false; - /** * Utility function to translate an array with shape [ varname => value ] into a self instance *