Merge "Replace VariableHolder::$forFilter"

This commit is contained in:
jenkins-bot 2023-01-05 21:23:24 +00:00 committed by Gerrit Code Review
commit 1ff0e96e38
5 changed files with 8 additions and 8 deletions

View file

@ -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 );
}

View file

@ -233,7 +233,8 @@ class RCVariableGenerator extends VariableGenerator {
$this->addEditVars(
$this->wikiPageFactory->newFromTitle( $title ),
$this->contextUser
$this->contextUser,
false
);
return $this;

View file

@ -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',

View file

@ -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 ) {

View file

@ -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
*