jenkins-bot has submitted this change and it was merged.

Change subject: Revert "(bug 49264, bug 48965) validate time format."
......................................................................


Revert "(bug 49264, bug 48965) validate time format."

This reverts commit 7accc7bfacbec38ec44415d33df12b6d8f022ed5

Strict validation when constructing TimeValue objects will break a lot
of things if we find invalid data in the database (as is the case for
wikidata.org). 

When merging this, we need to at least have a clear plan to handle the
resulting failures gracefully when rendering, diffing, serializing, 
importing, etc.

Change-Id: I8916062971114d6bc3188dd4f0322c28cc54403e
---
M DataValues/includes/values/TimeValue.php
M DataValues/tests/phpunit/includes/values/TimeValueTest.php
2 files changed, 4 insertions(+), 109 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DataValues/includes/values/TimeValue.php 
b/DataValues/includes/values/TimeValue.php
index e51acd4..8b71731 100644
--- a/DataValues/includes/values/TimeValue.php
+++ b/DataValues/includes/values/TimeValue.php
@@ -91,7 +91,7 @@
         *
         * @since 0.1
         *
-        * @var int
+        * @var integer
         */
        protected $timezone;
 
@@ -111,7 +111,6 @@
         * @param string $time
         * @param integer $timezone
         * @param integer $before
-        * @param integer $after
         * @param integer $precision
         * @param string $calendarModel
         *
@@ -120,10 +119,6 @@
        public function __construct( $time, $timezone, $before, $after, 
$precision, $calendarModel ) {
                if ( !is_string( $time ) ) {
                        throw new IllegalValueException( '$time needs to be a 
string' );
-               }
-
-               if ( !preg_match( 
'!^[-+]\d{1,16}-(0\d|1[012])-([012]\d|3[01])T([01]\d|2[0123]):[0-5]\d:([0-5]\d|6[012])Z$!',
 $time ) ) {
-                       throw new IllegalValueException( '$time needs to be a 
valid ISO 8601 date' );
                }
 
                if ( !is_integer( $timezone ) ) {
@@ -150,7 +145,7 @@
                        throw new IllegalValueException( '$precision out of 
allowed bounds' );
                }
 
-               if ( !is_string( $calendarModel ) ) { //XXX: enforce IRI? Or at 
least a size limit?
+               if ( !is_string( $calendarModel ) ) {
                        throw new IllegalValueException( '$calendarModel needs 
to be a string' );
                }
 
diff --git a/DataValues/tests/phpunit/includes/values/TimeValueTest.php 
b/DataValues/tests/phpunit/includes/values/TimeValueTest.php
index dd06062..e698eea 100644
--- a/DataValues/tests/phpunit/includes/values/TimeValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/TimeValueTest.php
@@ -117,12 +117,12 @@
                );
 
                $argLists[] = array(
-                       'DataValues\IllegalValueException',
+                       true,
                        '+00000002013-01-01T00:00:00Z',
                        0,
                        0,
                        0,
-                       333,
+                       0, // 0 == TimeValue::PRECISION_GIGAYEAR
                        'http://nyan.cat/original.php',
                );
 
@@ -162,106 +162,6 @@
                        0,
                        0,
                        -1,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       'bla',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013/01/01 00:00:00',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-22-01T00:00:00Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-01-35T00:00:00Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-01-01T27:00:00Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-01-01T00:66:00Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-01-01T00:00:66Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       'DataValues\IllegalValueException',
-                       '+00000002013-01-01T00:00:00+60',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       true,
-                       '+2013-01-01T00:00:00Z',
-                       0,
-                       0,
-                       0,
-                       TimeValue::PRECISION_SECOND,
-                       'http://nyan.cat/original.php',
-               );
-
-               $argLists[] = array(
-                       true,
-                       '-5-01-01T00:00:00Z',
-                       0,
-                       0,
-                       0,
                        TimeValue::PRECISION_SECOND,
                        'http://nyan.cat/original.php',
                );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8916062971114d6bc3188dd4f0322c28cc54403e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to