mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-12 00:38:23 +00:00
Unbreak filter edit form
In Ib7427e15f673a575738489476e604c387f449ddd, I thought that $parameters could've only been null if $action wasn't enabled, but actually, they're null even if the action is just not set. Which is true for all actions when creating a new filter, and all non-set actions when editing an existing one. Hence, revert the part that touched ViewEdit. Also add a selenium test to ensure that warn parameters are visible. Bug: T236286 Change-Id: I8150baa077208eb1fc54ebc1d8415a243d0f3bd3
This commit is contained in:
parent
cdee6802ea
commit
3a9eac9ad5
|
@ -479,10 +479,9 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
$output = '';
|
||||
|
||||
foreach ( $enabledActions as $action => $_ ) {
|
||||
if ( array_key_exists( $action, $actions ) ) {
|
||||
$output .= $this->buildConsequenceSelector(
|
||||
$action, $setActions[$action], $row, $actions[$action] );
|
||||
}
|
||||
$params = $actions[$action] ?? null;
|
||||
$output .= $this->buildConsequenceSelector(
|
||||
$action, $setActions[$action], $row, $params );
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
@ -492,12 +491,16 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
* @param string $action The action to build an editor for
|
||||
* @param bool $set Whether or not the action is activated
|
||||
* @param stdClass $row abuse_filter row object
|
||||
* @param array $parameters Action parameters
|
||||
* @param array|null $parameters Action parameters
|
||||
* @return string|\OOUI\FieldLayout
|
||||
*/
|
||||
private function buildConsequenceSelector( $action, $set, $row, array $parameters ) {
|
||||
private function buildConsequenceSelector( $action, $set, $row, ?array $parameters ) {
|
||||
$config = $this->getConfig();
|
||||
$user = $this->getUser();
|
||||
$actions = $config->get( 'AbuseFilterActions' );
|
||||
if ( empty( $actions[$action] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$readOnly = !AbuseFilter::canEditFilter( $user, $row );
|
||||
|
||||
|
@ -525,6 +528,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
$throttleFields = [];
|
||||
|
||||
if ( $set ) {
|
||||
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable $parameters is array here
|
||||
list( $throttleCount, $throttlePeriod ) = explode( ',', $parameters[1], 2 );
|
||||
|
||||
$throttleGroups = array_slice( $parameters, 2 );
|
||||
|
@ -795,6 +799,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
} else {
|
||||
if ( $set && count( $parameters ) === 1 ) {
|
||||
// Only blocktalk available
|
||||
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable $parameters is array here
|
||||
$blockTalk = $parameters[0];
|
||||
}
|
||||
if ( $config->get( 'AbuseFilterAnonBlockDuration' ) ) {
|
||||
|
|
|
@ -4,6 +4,7 @@ class ViewEditPage extends Page {
|
|||
get title() { return browser.element( '#firstHeading' ); }
|
||||
get filterId() { return browser.element( '#mw-abusefilter-edit-id .mw-input' ); }
|
||||
get hiddenEditor() { return browser.element( '#wpFilterRules' ); }
|
||||
get warnParams() { return browser.element( '#mw-abusefilter-warn-parameters' ); }
|
||||
open( id ) {
|
||||
super.openTitle( 'Special:AbuseFilter/' + id );
|
||||
}
|
||||
|
|
|
@ -24,5 +24,11 @@ describe( 'Special:AbuseFilter/new', function () {
|
|||
'',
|
||||
'the hidden rules editor should be empty'
|
||||
);
|
||||
|
||||
// @todo This assumes that warn is enabled in the config, but it usually is
|
||||
assert.ok(
|
||||
ViewEditPage.warnParams,
|
||||
'Warn action parameters should be on the page'
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue