From 627148d2bbf56a2645d3b5753e25b6d81009f3e1 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 14 Oct 2016 12:37:10 -0400 Subject: [PATCH] HTMLDateTimeField: Properly handle empty input i.e. don't parse it as "now" in date or datetime mode. Bug: T148200 Change-Id: I5a3839540222160e8d7376b5b961147c41d48885 --- includes/htmlform/fields/HTMLDateTimeField.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/htmlform/fields/HTMLDateTimeField.php b/includes/htmlform/fields/HTMLDateTimeField.php index 66f89f9564..3390a56771 100644 --- a/includes/htmlform/fields/HTMLDateTimeField.php +++ b/includes/htmlform/fields/HTMLDateTimeField.php @@ -126,6 +126,9 @@ class HTMLDateTimeField extends HTMLTextField { protected function parseDate( $value ) { $value = trim( $value ); + if ( $value === '' ) { + return false; + } if ( $this->mType === 'date' ) { $value .= ' T00:00:00+0000'; @@ -138,7 +141,7 @@ class HTMLDateTimeField extends HTMLTextField { $date = new DateTime( $value, new DateTimeZone( 'GMT' ) ); return $date->getTimestamp(); } catch ( Exception $ex ) { - return 0; + return false; } } -- 2.20.1