mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-13 17:27:20 +00:00
Catch FilterNotFoundException in ApiQueryAbuseLog
And report an invalid ID in this case. Also, assume that the filter is hidden if the global DB is not available, for consistency with the UI. Bug: T272593 Change-Id: Ic08023161d95be5cadc8837d3aaaf941cacd89bd
This commit is contained in:
parent
4f9676677c
commit
44dd0f6c96
|
@ -32,6 +32,7 @@ use InvalidArgumentException;
|
|||
use MediaWiki\Extension\AbuseFilter\AbuseFilter;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException;
|
||||
use MediaWiki\Extension\AbuseFilter\Filter\FilterNotFoundException;
|
||||
use MediaWiki\Extension\AbuseFilter\GlobalNameUtils;
|
||||
use MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
@ -106,17 +107,16 @@ class QueryAbuseLog extends ApiQueryBase {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
// @phan-suppress-next-line PhanImpossibleCondition
|
||||
if ( $foundInvalid ) {
|
||||
// @todo Tell what the invalid IDs are
|
||||
$this->addWarning( 'abusefilter-log-invalid-filter' );
|
||||
}
|
||||
if ( !$afPermManager->canViewPrivateFiltersLogs( $user ) ) {
|
||||
foreach ( $searchFilters as [ $filterID, $global ] ) {
|
||||
try {
|
||||
$isHidden = $lookup->getFilter( $filterID, $global )->isHidden();
|
||||
} catch ( CentralDBNotAvailableException $_ ) {
|
||||
// Conservatively assume it's hidden, like in SpecialAbuseLog
|
||||
$isHidden = true;
|
||||
} catch ( FilterNotFoundException $_ ) {
|
||||
$isHidden = false;
|
||||
$foundInvalid = true;
|
||||
}
|
||||
if ( $isHidden ) {
|
||||
$this->dieWithError(
|
||||
|
@ -125,6 +125,11 @@ class QueryAbuseLog extends ApiQueryBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $foundInvalid ) {
|
||||
// @todo Tell what the invalid IDs are
|
||||
$this->addWarning( 'abusefilter-log-invalid-filter' );
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->getResult();
|
||||
|
|
Loading…
Reference in a new issue