Ensure an array is passed to ApiEchoMute::lookupIds()

The nicer approach would be setting the parameter default to [],
but that breaks ApiSandbox.

Bug: T254699
Change-Id: I6c553e27248ff7d6c696f116cb34eb238dade440
This commit is contained in:
Gergő Tisza 2020-06-10 15:34:33 +02:00 committed by Gergő Tisza
parent ea200ace05
commit 153db72ec4

View file

@ -32,16 +32,18 @@ class ApiEchoMute extends ApiBase {
$mutelistInfo = self::$muteLists[ $params['type'] ];
$prefValue = $user->getOption( $mutelistInfo['pref'] );
$ids = $this->parsePref( $prefValue, $mutelistInfo['type'] );
$targetsToMute = $params['mute'] ?? [];
$targetsToUnmute = $params['unmute'] ?? [];
$changed = false;
$addIds = $this->lookupIds( $params['mute'], $mutelistInfo['type'] );
$addIds = $this->lookupIds( $targetsToMute, $mutelistInfo['type'] );
foreach ( $addIds as $id ) {
if ( !in_array( $id, $ids ) ) {
$ids[] = $id;
$changed = true;
}
}
$removeIds = $this->lookupIds( $params['unmute'], $mutelistInfo['type'] );
$removeIds = $this->lookupIds( $targetsToUnmute, $mutelistInfo['type'] );
foreach ( $removeIds as $id ) {
$index = array_search( $id, $ids );
if ( $index !== false ) {