pajoye                                   Thu, 11 Feb 2010 11:11:47 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=294880

Log:
- merge fix for: #45866,#50930, revert fix for #50392, Fixed a bug with the 'r' 
formatting function, added or fixed tests for #45866 and #46268

Bugs: http://bugs.php.net/45866 (Closed) decimal values fed to 
DateTime->modify() causes long execution times
      http://bugs.php.net/50930 (Closed) wrong date by php_date.c patch with 
ancient gcc/glibc versions
      http://bugs.php.net/50392 (Open) date_create_from_format enforces 6 
digits for 'u' format character
      http://bugs.php.net/46268 (Closed) When call DateTime#setTime, it seems 
to be called the last modify method too
      
Changed paths:
    _U  php/php-src/branches/PHP_5_3_2/
    U   php/php-src/branches/PHP_5_3_2/ext/date/config0.m4
    U   php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.c
    U   php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.re
    U   php/php-src/branches/PHP_5_3_2/ext/date/php_date.c
    A + php/php-src/branches/PHP_5_3_2/ext/date/tests/bug45866.phpt
        (from php/php-src/branches/PHP_5_3/ext/date/tests/bug45866.phpt:r294854)
    U   php/php-src/branches/PHP_5_3_2/ext/date/tests/bug46268.phpt
    U   php/php-src/branches/PHP_5_3_2/ext/date/tests/oo_002.phpt
    _U  php/php-src/branches/PHP_5_3_2/ext/tidy/tests/
    _U  
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt

Property changes on: php/php-src/branches/PHP_5_3_2
___________________________________________________________________
Modified: svn:mergeinfo
   - /php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292716,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293175-293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293974,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294855
/php/php-src/trunk:284726
   + /php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292716,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293175-293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293974,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294854-294855
/php/php-src/trunk:284726

Modified: php/php-src/branches/PHP_5_3_2/ext/date/config0.m4
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/config0.m4	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/config0.m4	2010-02-11 11:11:47 UTC (rev 294880)
@@ -16,8 +16,6 @@

 PHP_INSTALL_HEADERS([ext/date], [php_date.h lib/timelib.h lib/timelib_structs.h lib/timelib_config.h])

-AC_CHECK_FUNCS([llabs])
-
 cat > $ext_builddir/lib/timelib_config.h <<EOF
 #ifdef PHP_WIN32
 # include "config.w32.h"

Modified: php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.c	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.c	2010-02-11 11:11:47 UTC (rev 294880)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Thu Jan  7 07:52:26 2010 */
+/* Generated by re2c 0.13.5 on Wed Feb 10 15:19:23 2010 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -24157,8 +24157,8 @@

 					TIMELIB_CHECK_NUMBER;
 					tptr = ptr;
-					if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) {
-						add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin);
+					if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+						add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
 					} else {
 						s->time->f = (f / 1000000);
 					}

Modified: php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.re
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.re	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/lib/parse_date.re	2010-02-11 11:11:47 UTC (rev 294880)
@@ -1951,8 +1951,8 @@

 					TIMELIB_CHECK_NUMBER;
 					tptr = ptr;
-					if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || (ptr - tptr) < 1) {
-						add_pbf_error(s, "At least a single digit millisecond could not be found", string, begin);
+					if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+						add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
 					} else {
 						s->time->f = (f / 1000000);
 					}

Modified: php/php-src/branches/PHP_5_3_2/ext/date/php_date.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/php_date.c	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/php_date.c	2010-02-11 11:11:47 UTC (rev 294880)
@@ -35,13 +35,7 @@
 # include "win32/php_stdint.h"
 #endif

-#ifndef HAVE_LLABS
-# if defined(__GNUC__) && __GNUC__ < 3
-static __inline __int64_t llabs( __int64_t i ) { return i >= 0 ? i : -i; }
-# elif defined(NETWARE) && defined(__MWERKS__)
-static __inline long long llabs( long long i ) { return i >= 0 ? i : -i; }
-# endif
-#endif
+static __inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i; }

 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
@@ -1011,7 +1005,7 @@
 {
 	smart_str            string = {0};
 	int                  i, length;
-	char                 buffer[33];
+	char                 buffer[97];
 	timelib_time_offset *offset = NULL;
 	timelib_sll          isoweek, isoyear;
 	int                  rfc_colon;
@@ -1070,7 +1064,7 @@
 			/* year */
 			case 'L': length = slprintf(buffer, 32, "%d", timelib_is_leap((int) t->y)); break;
 			case 'y': length = slprintf(buffer, 32, "%02d", (int) t->y % 100); break;
-			case 'Y': length = slprintf(buffer, 32, "%s%04lld", t->y < 0 ? "-" : "", llabs((timelib_sll) t->y)); break;
+			case 'Y': length = slprintf(buffer, 32, "%s%04lld", t->y < 0 ? "-" : "", php_date_llabs((timelib_sll) t->y)); break;

 			/* time */
 			case 'a': length = slprintf(buffer, 32, "%s", t->h >= 12 ? "pm" : "am"); break;
@@ -1134,7 +1128,7 @@
 											localtime ? abs((offset->offset % 3600) / 60) : 0
 							  );
 					  break;
-			case 'r': length = slprintf(buffer, 32, "%3s, %02d %3s %04d %02d:%02d:%02d %c%02d%02d",
+			case 'r': length = slprintf(buffer, 96, "%3s, %02d %3s %04d %02d:%02d:%02d %c%02d%02d",
 							                php_date_short_day_name(t->y, t->m, t->d),
 											(int) t->d, mon_short_names[t->m - 1],
 											(int) t->y, (int) t->h, (int) t->i, (int) t->s,
@@ -2759,6 +2753,7 @@
 	char         *modify;
 	int           modify_len;
 	timelib_time *tmp_time;
+	timelib_error_container *err = NULL;

 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) {
 		RETURN_FALSE;
@@ -2766,7 +2761,18 @@
 	dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
 	DATE_CHECK_INITIALIZED(dateobj->time, DateTime);

-	tmp_time = timelib_strtotime(modify, modify_len, NULL, DATE_TIMEZONEDB);
+	tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB);
+
+	/* update last errors and warnings */
+	update_errors_warnings(err TSRMLS_CC);
+	if (err && err->error_count) {
+		/* spit out the first library error message, at least */
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify,
+			err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
+		timelib_time_dtor(tmp_time);
+		RETURN_FALSE;
+	}
+
 	memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time));
 	dateobj->time->have_relative = tmp_time->have_relative;
 	dateobj->time->sse_uptodate = 0;

Copied: php/php-src/branches/PHP_5_3_2/ext/date/tests/bug45866.phpt (from rev 294854, php/php-src/branches/PHP_5_3/ext/date/tests/bug45866.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/tests/bug45866.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3_2/ext/date/tests/bug45866.phpt	2010-02-11 11:11:47 UTC (rev 294880)
@@ -0,0 +1,24 @@
+--TEST--
+Bug #45866 (decimal values fed to DateTime->modify() causes long execution times)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "+1.61538461538 day" );
+echo $date->format( 'r' ), "\n";
+
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "61538461538 day" );
+echo $date->format( 'r' ), "\n";
+
+$date = new DateTime( '2009-07-29 16:44:23 Europe/London' );
+$date->modify( "£61538461538 day" );
+echo $date->format( 'r' ), "\n";
+?>
+--EXPECTF--
+Thu, 14 Aug 168488594 16:44:23 +0000
+Thu, 14 Aug 168488594 16:44:23 +0000
+
+Warning: DateTime::modify(): Failed to parse time string (£61538461538 day) at position 0 (%s): Unexpected character in %sbug45866.php on line 11
+Wed, 29 Jul 2009 16:44:23 +0100

Modified: php/php-src/branches/PHP_5_3_2/ext/date/tests/bug46268.phpt
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/tests/bug46268.phpt	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/tests/bug46268.phpt	2010-02-11 11:11:47 UTC (rev 294880)
@@ -7,10 +7,10 @@
 $now = new DateTime('2008-10-10 01:02:03');
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;

-$now->modify("1 day after");
+$now->modify("1 day");
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;

-$now->modify("1 hour after");
+$now->modify("1 hour");
 echo $now->format("Y-m-d H:i:s") . PHP_EOL;

 $now->setTime(0, 0, 0);

Modified: php/php-src/branches/PHP_5_3_2/ext/date/tests/oo_002.phpt
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/date/tests/oo_002.phpt	2010-02-11 11:08:44 UTC (rev 294879)
+++ php/php-src/branches/PHP_5_3_2/ext/date/tests/oo_002.phpt	2010-02-11 11:11:47 UTC (rev 294880)
@@ -9,7 +9,7 @@
 var_dump($d->format(DateTime::RFC822));
 $c = clone $d;
 var_dump($c->format(DateTime::RFC822));
-$d->modify("1 hour after");
+$d->modify("1 hour");
 $c->modify("1 second ago");
 var_dump($d->format(DateTime::RFC822));
 var_dump($c->format(DateTime::RFC822));


Property changes on: php/php-src/branches/PHP_5_3_2/ext/tidy/tests
___________________________________________________________________
Modified: svn:mergeinfo
   - /php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292716,292719,292765,293146,293152,293175-293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294855
/php/php-src/trunk/ext/tidy/tests:29815-29816,284726,287798-287941
   + /php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292716,292719,292765,293146,293152,293175-293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294854-294855
/php/php-src/trunk/ext/tidy/tests:29815-29816,284726,287798-287941


Property changes on: php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt
___________________________________________________________________
Modified: svn:mergeinfo
   - /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,292716,293146,293152,293175-293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294855
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:29815-29816,265951
   + /php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,292716,293146,293152,293175-293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293487,293502,293538,293548,293558,293588,293590,293597,293627,293644,293653,293655,293699,293726-293728,293732,293735,293762,293768,293804,293815-293816,293862,293894,293896-293897,293901-293906,293917-293918,293965-293966,293976-293977,293985,293998,294040,294053,294075,294077-294078,294081,294089,294094,294100,294102,294104,294126-294127,294129,294164,294251-294253,294255,294259-294261,294265,294267,294269,294272,294278,294285,294302-294304,294307-294308,294310,294312-294313,294315,294317,294320-294323,294333-294336,294353,294418,294421,294487,294498,294532,294571,294695,294697,294724,294814,294816,294825,294849,294854-294855
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:29815-29816,265951
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to