mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
Merge "Overhaul tag selector"
This commit is contained in:
commit
e03488b66a
|
@ -2444,6 +2444,10 @@ class AbuseFilter {
|
|||
|
||||
// If we've activated the 'tag' option, check the arguments for validity.
|
||||
if ( !empty( $actions['tag'] ) ) {
|
||||
if ( count( $actions['tag']['parameters'] ) === 0 ) {
|
||||
$validationStatus->error( 'tags-create-no-name' );
|
||||
return $validationStatus;
|
||||
}
|
||||
foreach ( $actions['tag']['parameters'] as $tag ) {
|
||||
$status = self::isAllowedTag( $tag );
|
||||
|
||||
|
|
|
@ -1232,6 +1232,12 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
$parameters[0] = $specMsg;
|
||||
} elseif ( $action === 'tag' ) {
|
||||
$parameters = explode( ',', trim( $request->getText( 'wpFilterTags' ) ) );
|
||||
if ( $parameters === [ '' ] ) {
|
||||
// Since it's not possible to manually add an empty tag, this only happens
|
||||
// if the form is submitted without touching the tag input field.
|
||||
// We pass an empty array so that the widget won't show an empty tag in the topbar
|
||||
$parameters = [];
|
||||
}
|
||||
}
|
||||
|
||||
$thisAction = [ 'action' => $action, 'parameters' => $parameters ];
|
||||
|
|
|
@ -414,6 +414,26 @@ class AbuseFilterSaveTest extends MediaWikiTestCase {
|
|||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'filterParameters' => [
|
||||
'rules' => '1!=0',
|
||||
'description' => 'Empty tag',
|
||||
'notes' => '',
|
||||
'tagEnabled' => true,
|
||||
'tagTags' => ''
|
||||
],
|
||||
'testData' => [
|
||||
'doingWhat' => 'Trying to save a filter with an empty tag',
|
||||
'expectedResult' => 'an error message saying that the tag name must be specified',
|
||||
'expectedMessage' => 'tags-create-no-name',
|
||||
'shouldFail' => true,
|
||||
'shouldBeSaved' => false,
|
||||
'customUserGroup' => '',
|
||||
'needsOtherFilters' => false
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'filterParameters' => [
|
||||
|
|
Loading…
Reference in a new issue