From: Brad Jorsch Date: Fri, 14 Oct 2016 16:37:10 +0000 (-0400) Subject: HTMLDateTimeField: Properly handle empty input X-Git-Tag: 1.31.0-rc.0~5113^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=627148d2bbf56a2645d3b5753e25b6d81009f3e1;p=lhc%2Fweb%2Fwiklou.git HTMLDateTimeField: Properly handle empty input i.e. don't parse it as "now" in date or datetime mode. Bug: T148200 Change-Id: I5a3839540222160e8d7376b5b961147c41d48885 --- 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; } }