Merge "Overhaul tag selector"

This commit is contained in:
jenkins-bot 2019-04-06 12:35:20 +00:00 committed by Gerrit Code Review
commit e03488b66a
3 changed files with 30 additions and 0 deletions

View file

@ -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 );

View file

@ -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 ];

View file

@ -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' => [