Remove the hacky 'context' variable

First step for removing meta-variables, the second one being removing
global_log_ids and local_log_ids.

Change-Id: I01cd79771c0ee0865abaef6757a930aacd8138d2
This commit is contained in:
Daimona Eaytoy 2019-01-05 18:30:37 +01:00
parent 6de4d426f0
commit f700139215
3 changed files with 6 additions and 9 deletions

View file

@ -228,7 +228,7 @@ class AFComputedVariable {
);
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
if ( $vars->getVar( 'context' )->toString() == 'filter' ) {
if ( $vars->forFilter ) {
$links = $this->getLinksFromDB( $article );
$logger->debug( 'Loading old links from DB' );
} elseif ( $article->getContentModel() === CONTENT_MODEL_WIKITEXT ) {

View file

@ -1116,7 +1116,7 @@ class AbuseFilter {
Hooks::run( 'AbuseFilter-filterAction', [ &$vars, $title ] );
$vars->addHolders( self::generateStaticVars() );
$vars->setVar( 'context', 'filter' );
$vars->forFilter = true;
$vars->setVar( 'timestamp', time() );
// Get the stash key based on the relevant "input" variables
@ -2737,7 +2737,6 @@ class AbuseFilter {
return null;
}
if ( $vars ) {
$vars->setVar( 'context', 'generated' );
$vars->setVar( 'timestamp', wfTimestamp( TS_UNIX, $row->rc_timestamp ) );
$vars->addHolders( self::generateStaticVars() );
}

View file

@ -5,7 +5,10 @@ class AbuseFilterVariableHolder {
public $mVars = [];
/** @var string[] Variables used to store meta-data, we'd better be safe. See T191715 */
public static $varBlacklist = [ 'context', 'global_log_ids', 'local_log_ids' ];
public static $varBlacklist = [ 'global_log_ids', 'local_log_ids' ];
/** @var bool Whether this object is being used for an ongoing action being filtered */
public $forFilter = false;
/** @var int 2 is the default and means that new variables names (from T173889) should be used.
* 1 means that the old ones should be used, e.g. if this object is constructed from an
@ -91,11 +94,6 @@ class AbuseFilterVariableHolder {
}
}
public function __wakeup() {
// Reset the context.
$this->setVar( 'context', 'stored' );
}
/**
* Export all variables stored in this object as string
*