From 1197eb6b4187cea62f8af8d712af7dd0e3891358 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 10 Aug 2019 18:34:42 +0200 Subject: [PATCH] Make parser aware of the filter it is parsing This information will mostly be used for debugging purposes. Change-Id: Ia1bcc2acc22aba97d855382b5b173ac3d5f2c54b --- includes/AbuseFilterRunner.php | 1 + includes/parser/AbuseFilterParser.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/includes/AbuseFilterRunner.php b/includes/AbuseFilterRunner.php index e40c421c1..32825906a 100644 --- a/includes/AbuseFilterRunner.php +++ b/includes/AbuseFilterRunner.php @@ -377,6 +377,7 @@ class AbuseFilterRunner { AbuseFilter::cacheFilter( $filterName, $row ); $pattern = trim( $row->af_pattern ); + $this->parser->setFilter( $filterName ); $result = AbuseFilter::checkConditions( $pattern, $this->parser, true, $filterName ); $actualExtra = AFComputedVariable::$profilingExtraTime - $origExtraTime; diff --git a/includes/parser/AbuseFilterParser.php b/includes/parser/AbuseFilterParser.php index 31469ecbd..3afe00d4d 100644 --- a/includes/parser/AbuseFilterParser.php +++ b/includes/parser/AbuseFilterParser.php @@ -40,6 +40,11 @@ class AbuseFilterParser { */ protected $condLimitEnabled = true; + /** + * @var string|null The ID of the filter being parsed, if available. Can also be "global-$ID" + */ + protected $mFilter; + public static $mFunctions = [ 'lcase' => 'funcLc', 'ucase' => 'funcUc', @@ -110,6 +115,13 @@ class AbuseFilterParser { } } + /** + * @param string $filter + */ + public function setFilter( $filter ) { + $this->mFilter = $filter; + } + /** * @return int */ @@ -158,6 +170,7 @@ class AbuseFilterParser { $this->mShortCircuit = false; $this->mAllowShort = true; $this->mCondCount = 0; + $this->mFilter = null; } /**