From 2b0b187bae8a42b4dca68a446ba5050bb7de6c50 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Tue, 8 Nov 2022 12:57:37 +0100 Subject: [PATCH] HTMLFormField: Treat null as missing value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit null is the “default default” in getDefault() (if the method has neither been overridden nor $this->mDefault been set), so it can appear in the field data. Don’t pass it to the validator (which may not expect a null value) if the param is supposed to be required. Bug: T319219 Change-Id: Ib6bb119b841ffcbb5e7fb30014355dc90ba9b46e --- includes/htmlform/HTMLFormField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index dd29b3ece98..65a9af25344 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -399,7 +399,7 @@ abstract class HTMLFormField { if ( isset( $this->mParams['required'] ) && $this->mParams['required'] !== false - && ( $value === '' || $value === false ) + && ( $value === '' || $value === false || $value === null ) ) { return $this->msg( 'htmlform-required' ); }