During the overhaul, the FilterRunner class has become the core of AbuseFilter. While most of the code has been moved to standalone services, the interface is not clean enough.
Proposed organization using inheritance:
class BaseFilterRunner { public run() : Status { $result = $this->getResult(); return $this->takeConsequences( $result ); } protected getResult(); abstract protected takeConsequences( $result ) : Status; }
- getResult() runs filters and returns information about filter matches, profiling, etc.
- takeConsequences() gets the result and takes consequences.
The new classes will be:
class FilterRunner extends BaseFilterRunner { protected takeConsequences( $result ) : Status { // run Consequences, log matches and profiling data } } class EditStashAwareFilterRunner extends FilterRunner { protected EditStashCache $cache; protected getResult() { $result = $this->cache->seek(); if ( $result === false ) { $result = parent::getResult(); } return $result; } } class ForStashFilterRunner extends BaseFilterRunner { protected EditStashCache $cache; protected takeConsequences( $result ) : Status { $this->cache->save( $result ); return Status::newGood(); } }
FilterRunnerFactory will provide newRunner, newForStashRunner, etc. methods.
Each hook will request the appropriate runner from the factory.
All of this gets its own namespace.