Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315972

Change subject: HTMLDateTimeField: Properly handle empty input
......................................................................

HTMLDateTimeField: Properly handle empty input

i.e. don't parse it as "now" in date or datetime mode.

Bug: T148200
Change-Id: I5a3839540222160e8d7376b5b961147c41d48885
---
M includes/htmlform/fields/HTMLDateTimeField.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/315972/1

diff --git a/includes/htmlform/fields/HTMLDateTimeField.php 
b/includes/htmlform/fields/HTMLDateTimeField.php
index 66f89f9..3390a56 100644
--- a/includes/htmlform/fields/HTMLDateTimeField.php
+++ b/includes/htmlform/fields/HTMLDateTimeField.php
@@ -126,6 +126,9 @@
 
        protected function parseDate( $value ) {
                $value = trim( $value );
+               if ( $value === '' ) {
+                       return false;
+               }
 
                if ( $this->mType === 'date' ) {
                        $value .= ' T00:00:00+0000';
@@ -138,7 +141,7 @@
                        $date = new DateTime( $value, new DateTimeZone( 'GMT' ) 
);
                        return $date->getTimestamp();
                } catch ( Exception $ex ) {
-                       return 0;
+                       return false;
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/315972
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a3839540222160e8d7376b5b961147c41d48885
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to