From: Roan Kattouw Date: Tue, 11 Jul 2017 18:29:17 +0000 (-0700) Subject: HTMLUsersMultiselectField: Handle empty value properly X-Git-Tag: 1.31.0-rc.0~2720^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=7c0a58393b795ba641033586b41b54828d448781;p=lhc%2Fweb%2Fwiklou.git HTMLUsersMultiselectField: Handle empty value properly If the string value is '' (empty string), the array value should be [] (empty array), not [''] (array of one element which is an empty string). Bug: T169384 Change-Id: I558f3890af05efb6eaa18403467c0a05f44af12a --- diff --git a/includes/htmlform/fields/HTMLUsersMultiselectField.php b/includes/htmlform/fields/HTMLUsersMultiselectField.php index 286cb8d31d..c2d26a3103 100644 --- a/includes/htmlform/fields/HTMLUsersMultiselectField.php +++ b/includes/htmlform/fields/HTMLUsersMultiselectField.php @@ -70,7 +70,7 @@ class HTMLUsersMultiselectField extends HTMLUserTextField { if ( !is_null( $value ) ) { // $value is a string, but the widget expects an array - $params['default'] = explode( "\n", $value ); + $params['default'] = $value === '' ? [] : explode( "\n", $value ); } // Make the field auto-infusable when it's used inside a legacy HTMLForm rather than OOUIHTMLForm