diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-06-21 13:48:35 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-06-21 13:48:35 +0200 |
| commit | 706ac6417162d94eb701952d40df136cd9528b56 (patch) | |
| tree | 1858b0f397d16519dbd73c998d7a89001af362d2 /ext/date | |
| parent | e2d52710fa3134e72662116b3b495f5a22cf9c72 (diff) | |
| download | php-706ac6417162d94eb701952d40df136cd9528b56.tar.gz | |
New upstream version 5.5.0+dfsgupstream/5.5.0+dfsg
Diffstat (limited to 'ext/date')
| -rw-r--r-- | ext/date/php_date.c | 15 | ||||
| -rw-r--r-- | ext/date/tests/bug45682.phpt | 4 | ||||
| -rw-r--r-- | ext/date/tests/bug49778.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/bug52113.phpt | 26 | ||||
| -rw-r--r-- | ext/date/tests/bug52808.phpt | 12 | ||||
| -rw-r--r-- | ext/date/tests/bug53437.phpt | 6 | ||||
| -rw-r--r-- | ext/date/tests/bug53437_var2.phpt | 6 | ||||
| -rw-r--r-- | ext/date/tests/bug53437_var3.phpt | 12 | ||||
| -rw-r--r-- | ext/date/tests/bug53437_var4.phpt | 64 | ||||
| -rw-r--r-- | ext/date/tests/bug53437_var5.phpt | 47 | ||||
| -rw-r--r-- | ext/date/tests/bug60774.phpt | 2 | ||||
| -rw-r--r-- | ext/date/tests/date_diff1.phpt | 4 | ||||
| -rw-r--r-- | ext/date/tests/date_sunrise_and_sunset_basic.phpt | 2 |
13 files changed, 153 insertions, 49 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d09d254c1..28ac86b11 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2384,18 +2384,9 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC) return props; } -#define PHP_DATE_INTERVAL_ADD_PROPERTY_I64(n, f) \ - do { \ - char i64_buf[DATE_I64_BUF_LEN]; \ - MAKE_STD_ZVAL(zv); \ - DATE_I64A(intervalobj->diff->f, i64_buf, DATE_I64_BUF_LEN); \ - ZVAL_STRING(zv, i64_buf, 1); \ - zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL); \ - } while(0); - #define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \ MAKE_STD_ZVAL(zv); \ - ZVAL_LONG(zv, intervalobj->diff->f); \ + ZVAL_LONG(zv, (long)intervalobj->diff->f); \ zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL); PHP_DATE_INTERVAL_ADD_PROPERTY("y", y); @@ -2409,14 +2400,14 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC) PHP_DATE_INTERVAL_ADD_PROPERTY("first_last_day_of", first_last_day_of); PHP_DATE_INTERVAL_ADD_PROPERTY("invert", invert); if (intervalobj->diff->days != -99999) { - PHP_DATE_INTERVAL_ADD_PROPERTY_I64("days", days); + PHP_DATE_INTERVAL_ADD_PROPERTY("days", days); } else { MAKE_STD_ZVAL(zv); ZVAL_FALSE(zv); zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL); } PHP_DATE_INTERVAL_ADD_PROPERTY("special_type", special.type); - PHP_DATE_INTERVAL_ADD_PROPERTY_I64("special_amount", special.amount); + PHP_DATE_INTERVAL_ADD_PROPERTY("special_amount", special.amount); PHP_DATE_INTERVAL_ADD_PROPERTY("have_weekday_relative", have_weekday_relative); PHP_DATE_INTERVAL_ADD_PROPERTY("have_special_relative", have_special_relative); diff --git a/ext/date/tests/bug45682.phpt b/ext/date/tests/bug45682.phpt index 094c7fdf4..ea8fa9470 100644 --- a/ext/date/tests/bug45682.phpt +++ b/ext/date/tests/bug45682.phpt @@ -34,11 +34,11 @@ object(DateInterval)#%d (15) { ["invert"]=> int(0) ["days"]=> - string(1) "3" + int(3) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug49778.phpt b/ext/date/tests/bug49778.phpt index cc52a23b2..2062d6916 100644 --- a/ext/date/tests/bug49778.phpt +++ b/ext/date/tests/bug49778.phpt @@ -34,7 +34,7 @@ object(DateInterval)#1 (15) { ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug52113.phpt b/ext/date/tests/bug52113.phpt index 862e92e96..f4730c6a4 100644 --- a/ext/date/tests/bug52113.phpt +++ b/ext/date/tests/bug52113.phpt @@ -54,17 +54,17 @@ object(DateInterval)#3 (15) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } -string(328) "O:12:"DateInterval":15:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:1:"0";s:12:"special_type";i:0;s:14:"special_amount";s:1:"0";s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}" +string(320) "O:12:"DateInterval":15:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:7:"weekday";i:0;s:16:"weekday_behavior";i:0;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";i:0;s:12:"special_type";i:0;s:14:"special_amount";i:0;s:21:"have_weekday_relative";i:0;s:21:"have_special_relative";i:0;}" DateInterval::__set_state(array( 'y' => 0, 'm' => 0, @@ -76,9 +76,9 @@ DateInterval::__set_state(array( 'weekday_behavior' => 0, 'first_last_day_of' => 0, 'invert' => 0, - 'days' => '0', + 'days' => 0, 'special_type' => 0, - 'special_amount' => '0', + 'special_amount' => 0, 'have_weekday_relative' => 0, 'have_special_relative' => 0, ))object(DateInterval)#5 (15) { @@ -103,11 +103,11 @@ DateInterval::__set_state(array( ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -150,11 +150,11 @@ object(DatePeriod)#6 (6) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -187,11 +187,11 @@ object(DateInterval)#8 (15) { ["invert"]=> int(1) ["days"]=> - string(4) "2400" + int(2400) ["special_type"]=> int(0) ["special_amount"]=> - string(2) "-1" + int(-1) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -234,11 +234,11 @@ object(DatePeriod)#9 (6) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug52808.phpt b/ext/date/tests/bug52808.phpt index e3b38bb5f..1f0fc84cd 100644 --- a/ext/date/tests/bug52808.phpt +++ b/ext/date/tests/bug52808.phpt @@ -47,11 +47,11 @@ object(DateInterval)#%d (15) { ["invert"]=> int(1) ["days"]=> - string(3) "437" + int(437) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -79,11 +79,11 @@ object(DateInterval)#%d (15) { ["invert"]=> int(0) ["days"]=> - string(3) "294" + int(294) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -111,11 +111,11 @@ object(DateInterval)#%d (15) { ["invert"]=> int(0) ["days"]=> - string(3) "294" + int(294) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug53437.phpt b/ext/date/tests/bug53437.phpt index 7a282ab6c..2ea091453 100644 --- a/ext/date/tests/bug53437.phpt +++ b/ext/date/tests/bug53437.phpt @@ -77,7 +77,7 @@ object(DatePeriod)#1 (6) { ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -132,11 +132,11 @@ object(DatePeriod)#5 (6) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug53437_var2.phpt b/ext/date/tests/bug53437_var2.phpt index 70565960e..50aebda57 100644 --- a/ext/date/tests/bug53437_var2.phpt +++ b/ext/date/tests/bug53437_var2.phpt @@ -39,7 +39,7 @@ object(DateInterval)#1 (15) { ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> @@ -67,11 +67,11 @@ object(DateInterval)#2 (15) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/bug53437_var3.phpt b/ext/date/tests/bug53437_var3.phpt index 06f68df61..82b90f559 100644 --- a/ext/date/tests/bug53437_var3.phpt +++ b/ext/date/tests/bug53437_var3.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #53437 DateInterval unserialize bad data +Bug #53437 DateInterval unserialize bad data, 32 bit +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) { die('skip 32 bit only'); } ?> --FILE-- <?php $s = 'O:12:"DateInterval":15:{s:1:"y";s:1:"2";s:1:"m";s:1:"0";s:1:"d";s:3:"bla";s:1:"h";s:1:"6";s:1:"i";s:1:"8";s:1:"s";s:1:"0";s:7:"weekday";i:10;s:16:"weekday_behavior";i:10;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:4:"aoeu";s:12:"special_type";i:0;s:14:"special_amount";s:21:"234523452345234532455";s:21:"have_weekday_relative";i:21474836489;s:21:"have_special_relative";s:3:"bla";}'; @@ -9,8 +11,8 @@ var_dump($di); ?> ==DONE== ---EXPECT-- -object(DateInterval)#1 (15) { +--EXPECTF-- +object(DateInterval)#%d (15) { ["y"]=> int(2) ["m"]=> @@ -32,11 +34,11 @@ object(DateInterval)#1 (15) { ["invert"]=> int(0) ["days"]=> - string(1) "0" + int(0) ["special_type"]=> int(0) ["special_amount"]=> - string(19) "9223372036854775807" + int(-1) ["have_weekday_relative"]=> int(9) ["have_special_relative"]=> diff --git a/ext/date/tests/bug53437_var4.phpt b/ext/date/tests/bug53437_var4.phpt new file mode 100644 index 000000000..88fd81c9d --- /dev/null +++ b/ext/date/tests/bug53437_var4.phpt @@ -0,0 +1,64 @@ +--TEST-- +Bug #53437 (Check that var_dump out is the same using the whole object or it's single properties), variation 4 +--INI-- +date.timezone = Europe/Berlin +--FILE-- +<?php +$dt = new DateTime('2009-10-11'); + +$df = $dt->diff(new DateTime('2009-10-13')); + +var_dump($df, + $df->y, + $df->m, + $df->d, + $df->h, + $df->i, + $df->s, + $df->invert, + $df->days); + +?> +==DONE== +--EXPECTF-- +object(DateInterval)#%d (15) { + ["y"]=> + int(0) + ["m"]=> + int(0) + ["d"]=> + int(2) + ["h"]=> + int(0) + ["i"]=> + int(0) + ["s"]=> + int(0) + ["weekday"]=> + int(0) + ["weekday_behavior"]=> + int(0) + ["first_last_day_of"]=> + int(0) + ["invert"]=> + int(0) + ["days"]=> + int(2) + ["special_type"]=> + int(0) + ["special_amount"]=> + int(0) + ["have_weekday_relative"]=> + int(0) + ["have_special_relative"]=> + int(0) +} +int(0) +int(0) +int(2) +int(0) +int(0) +int(0) +int(0) +int(2) +==DONE== diff --git a/ext/date/tests/bug53437_var5.phpt b/ext/date/tests/bug53437_var5.phpt new file mode 100644 index 000000000..e95fcdae9 --- /dev/null +++ b/ext/date/tests/bug53437_var5.phpt @@ -0,0 +1,47 @@ +--TEST-- +Bug #53437 DateInterval unserialize bad data, 64 bit +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) { die('skip true 64 bit only'); } ?> +--FILE-- +<?php +$s = 'O:12:"DateInterval":15:{s:1:"y";s:1:"2";s:1:"m";s:1:"0";s:1:"d";s:3:"bla";s:1:"h";s:1:"6";s:1:"i";s:1:"8";s:1:"s";s:1:"0";s:7:"weekday";i:10;s:16:"weekday_behavior";i:10;s:17:"first_last_day_of";i:0;s:6:"invert";i:0;s:4:"days";s:4:"aoeu";s:12:"special_type";i:0;s:14:"special_amount";s:21:"234523452345234532455";s:21:"have_weekday_relative";i:21474836489;s:21:"have_special_relative";s:3:"bla";}'; + +$di = unserialize($s); +var_dump($di); + +?> +==DONE== +--EXPECTF-- +object(DateInterval)#%d (15) { + ["y"]=> + int(2) + ["m"]=> + int(0) + ["d"]=> + int(0) + ["h"]=> + int(6) + ["i"]=> + int(8) + ["s"]=> + int(0) + ["weekday"]=> + int(10) + ["weekday_behavior"]=> + int(10) + ["first_last_day_of"]=> + int(0) + ["invert"]=> + int(0) + ["days"]=> + int(0) + ["special_type"]=> + int(0) + ["special_amount"]=> + int(9223372036854775807) + ["have_weekday_relative"]=> + int(9) + ["have_special_relative"]=> + int(0) +} +==DONE== diff --git a/ext/date/tests/bug60774.phpt b/ext/date/tests/bug60774.phpt index 865928dd8..7045cd778 100644 --- a/ext/date/tests/bug60774.phpt +++ b/ext/date/tests/bug60774.phpt @@ -34,7 +34,7 @@ object(DateInterval)#1 (%d) { ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/date_diff1.phpt b/ext/date/tests/date_diff1.phpt index 3f3d1da7a..a908cdba7 100644 --- a/ext/date/tests/date_diff1.phpt +++ b/ext/date/tests/date_diff1.phpt @@ -50,11 +50,11 @@ object(DateInterval)#3 (15) { ["invert"]=> int(0) ["days"]=> - string(2) "33" + int(33) ["special_type"]=> int(0) ["special_amount"]=> - string(1) "0" + int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> diff --git a/ext/date/tests/date_sunrise_and_sunset_basic.phpt b/ext/date/tests/date_sunrise_and_sunset_basic.phpt index a96fa8303..f89b63fd9 100644 --- a/ext/date/tests/date_sunrise_and_sunset_basic.phpt +++ b/ext/date/tests/date_sunrise_and_sunset_basic.phpt @@ -14,7 +14,7 @@ offset: +1 GMT echo "Basic test for date_sunrise() and date_sunset()\n"; -// supress date() function strict msgs +// suppress date() function strict msgs error_reporting(E_ALL & ~E_STRICT); echo date("D M d Y") . ', sunrise time : ' . date_sunrise(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1) . "\n"; |
