mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-12 00:38:23 +00:00
Merge "Replace VariableHolder::$forFilter"
This commit is contained in:
commit
1ff0e96e38
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,8 @@ class RCVariableGenerator extends VariableGenerator {
|
|||
|
||||
$this->addEditVars(
|
||||
$this->wikiPageFactory->newFromTitle( $title ),
|
||||
$this->contextUser
|
||||
$this->contextUser,
|
||||
false
|
||||
);
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue