Re: com php-src: Fixed bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date): ext/date/php_date.c
ext/date/tests/DateTime_format_basic2.phpt ext/date/tests/DateTime_verify.phpt ext/date/tests/bug52063.phpt ext/date/tests/bug53879.phpt
ext/date/tests/date_constants.phpt ext/date/tests/gmdate_variation13.phpt ext/date/tests/test-parse-from-format.phpt

From: Date: Mon, 02 Dec 2013 19:06:53 +0000
Subject: Re: com php-src: Fixed bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date): ext/date/php_date.c
ext/date/tests/DateTime_format_basic2.phpt ext/date/tests/DateTime_verify.phpt ext/date/tests/bug52063.phpt ext/date/tests/bug53879.phpt
ext/date/tests/date_constants.phpt ext/date/tests/gmdate_variation13.phpt ext/date/tests/test-parse-from-format.phpt
References: 1  Groups: php.cvs php.internals 
Request: Send a blank email to internals+get-70471@lists.php.net to get a copy of this message
On Wed, 2013-11-27 at 21:59 +0000, Derick Rethans wrote: > Commit: 23ab2575e1be062c2d5e3f80d3ff40cabe14fa2c > Author: Derick Rethans <github@derickrethans.nl> Wed, 27 Nov 2013 21:59:46 > +0000 > Parents: 504c60dc4451b8ede8814530dbfec0ef485f0ca6 > Branches: master > > Link: > http://git.php.net/?p=php-src.git;a=commitdiff;h=23ab2575e1be062c2d5e3f80d3ff40cabe14fa2c > > Log: > Fixed bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date) > Looks like since this commit the travis builds are broken: 001+ Warning: DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/travis/build/php/php-src/ext/date/tests/bug53879.php on line 2 > Bugs: > https://bugs.php.net/53879 > > Changed paths: > M ext/date/php_date.c > M ext/date/tests/DateTime_format_basic2.phpt > M ext/date/tests/DateTime_verify.phpt > M ext/date/tests/bug52063.phpt > A ext/date/tests/bug53879.phpt > M ext/date/tests/date_constants.phpt > M ext/date/tests/gmdate_variation13.phpt > M ext/date/tests/test-parse-from-format.phpt > > > Diff: > diff --git a/ext/date/php_date.c b/ext/date/php_date.c > index 7e4de09..b7da07c 100644 > --- a/ext/date/php_date.c > +++ b/ext/date/php_date.c > @@ -752,6 +752,14 @@ PHP_RSHUTDOWN_FUNCTION(date) > > #define DATE_FORMAT_ISO8601 "Y-m-d\\TH:i:sO" > > +/* > + * This comes from various sources that like to contradict. I'm going with the > + * format here because of: > + * kçÌ{h¿ólsã׌MX > http://msdn.microsoft.com/en-us/library/windows/desktop/aa384321%28v=vs.85%29.aspx > + * and http://curl.haxx.se/rfc/cookie_spec.html > + */ > +#define DATE_FORMAT_COOKIE "l, d-M-Y H:i:s T" > + > #define DATE_TZ_ERRMSG \ > "It is not safe to rely on the system's timezone settings. You are " \ > "*required* to use the date.timezone setting or the " \ > @@ -783,7 +791,7 @@ PHP_MINIT_FUNCTION(date) > * with the variations that the only legal time zone is GMT > * and the separators between the elements of the date must be dashes." > */ > - REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_RFC850, CONST_CS | > CONST_PERSISTENT); > + REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_COOKIE, CONST_CS | > CONST_PERSISTENT); > REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS | > CONST_PERSISTENT); > REGISTER_STRING_CONSTANT("DATE_RFC822", DATE_FORMAT_RFC822, CONST_CS | > CONST_PERSISTENT); > REGISTER_STRING_CONSTANT("DATE_RFC850", DATE_FORMAT_RFC850, CONST_CS | > CONST_PERSISTENT); > @@ -1948,7 +1956,7 @@ static void date_register_classes(TSRMLS_D) > zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, > sizeof(value)-1 TSRMLS_CC); > > REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339); > - REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_RFC850); > + REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE); > REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601); > REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822); > REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850); > diff --git a/ext/date/tests/DateTime_format_basic2.phpt > b/ext/date/tests/DateTime_format_basic2.phpt > index d7adaa5..016fa7b 100644 > --- a/ext/date/tests/DateTime_format_basic2.phpt > +++ b/ext/date/tests/DateTime_format_basic2.phpt > @@ -31,7 +31,7 @@ var_dump( $date->format( DateTime::W3C) ) ; > --EXPECT-- > *** Testing date_format() : basic functionality - formatting coinstants *** > string(25) "2005-07-14T22:30:41+01:00" > -string(32) "Thursday, 14-Jul-05 22:30:41 BST" > +string(34) "Thursday, 14-Jul-2005 22:30:41 BST" > string(24) "2005-07-14T22:30:41+0100" > string(29) "Thu, 14 Jul 05 22:30:41 +0100" > string(32) "Thursday, 14-Jul-05 22:30:41 BST" > diff --git a/ext/date/tests/DateTime_verify.phpt b/ext/date/tests/DateTime_verify.phpt > index a03911f..c790974 100644 > --- a/ext/date/tests/DateTime_verify.phpt > +++ b/ext/date/tests/DateTime_verify.phpt > @@ -160,7 +160,7 @@ array(11) { > ["ATOM"]=> > string(13) "Y-m-d\TH:i:sP" > ["COOKIE"]=> > - string(16) "l, d-M-y H:i:s T" > + string(16) "l, d-M-Y H:i:s T" > ["ISO8601"]=> > string(13) "Y-m-d\TH:i:sO" > ["RFC822"]=> > @@ -180,4 +180,4 @@ array(11) { > ["W3C"]=> > string(13) "Y-m-d\TH:i:sP" > } > -===DONE=== > \ No newline at end of file > +===DONE=== > diff --git a/ext/date/tests/bug52063.phpt b/ext/date/tests/bug52063.phpt > index af9da9e..7364a80 100644 > --- a/ext/date/tests/bug52063.phpt > +++ b/ext/date/tests/bug52063.phpt > @@ -11,5 +11,5 @@ echo $a->format(DateTime::COOKIE); > echo "\n"; > ?> > --EXPECTF-- > -Thursday, 01-Jan-09 00:00:00 WET > -Thursday, 01-Jan-09 00:00:00 WET > +Thursday, 01-Jan-2009 00:00:00 WET > +Thursday, 01-Jan-2009 00:00:00 WET > diff --git a/ext/date/tests/bug53879.phpt b/ext/date/tests/bug53879.phpt > new file mode 100644 > index 0000000..64c0f18 > --- /dev/null > +++ b/ext/date/tests/bug53879.phpt > @@ -0,0 +1,14 @@ > +--TEST-- > +Bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date) > +--FILE-- > +<?php > +$date = DateTime::createFromFormat(DateTime::COOKIE, "Mon, 21-Jan-2041 15:24:52 > GMT"); > +print_r($date); > +?> > +--EXPECTF-- > +DateTime Object > +( > + [date] => 2041-01-21 15:24:52 > + [timezone_type] => 2 > + [timezone] => GMT > +) > diff --git a/ext/date/tests/date_constants.phpt b/ext/date/tests/date_constants.phpt > index 132e241..b9fce8c 100644 > --- a/ext/date/tests/date_constants.phpt > +++ b/ext/date/tests/date_constants.phpt > @@ -41,8 +41,8 @@ Date constants > --EXPECT-- > string(25) "2006-07-01T14:27:30+02:00" > string(25) "2006-05-30T14:32:13+02:00" > -string(33) "Saturday, 01-Jul-06 14:27:30 CEST" > -string(32) "Tuesday, 30-May-06 14:32:13 CEST" > +string(35) "Saturday, 01-Jul-2006 14:27:30 CEST" > +string(34) "Tuesday, 30-May-2006 14:32:13 CEST" > string(24) "2006-07-01T14:27:30+0200" > string(24) "2006-05-30T14:32:13+0200" > string(29) "Sat, 01 Jul 06 14:27:30 +0200" > diff --git a/ext/date/tests/gmdate_variation13.phpt b/ext/date/tests/gmdate_variation13.phpt > index 5a19ae2..1d1f434 100644 > --- a/ext/date/tests/gmdate_variation13.phpt > +++ b/ext/date/tests/gmdate_variation13.phpt > @@ -45,7 +45,7 @@ string(25) "2008-08-08T08:08:08+00:00" > string(%d) "%s" > > --DATE_COOKIE Constant-- > -string(30) "Friday, 08-Aug-08 08:08:08 GMT" > +string(32) "Friday, 08-Aug-2008 08:08:08 GMT" > string(%d) "%s" > > --DATE_RFC822 Constant-- > @@ -79,4 +79,4 @@ string(%d) "%s" > --DATE_W3C Constant-- > string(25) "2008-08-08T08:08:08+00:00" > string(%d) "%s" > -===DONE=== > \ No newline at end of file > +===DONE=== > diff --git a/ext/date/tests/test-parse-from-format.phpt > b/ext/date/tests/test-parse-from-format.phpt > index 2bf9c4e..5bb5fe5 100644 > --- a/ext/date/tests/test-parse-from-format.phpt > +++ b/ext/date/tests/test-parse-from-format.phpt > @@ -32,8 +32,8 @@ object(DateTime)#2 (3) { > string(6) "+02:00" > } > > -string(16) "l, d-M-y H:i:s T" > -string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200" > +string(16) "l, d-M-Y H:i:s T" > +string(38) "Tuesday, 08-Jul-2008 22:14:12 GMT+0200" > object(DateTime)#1 (3) { > ["date"]=> > string(19) "2008-07-08 22:14:12" > > -- Regards, Mike

« previous php.internals (#70471) next »