From 02f39220470d82066965b7d4657cadf40ac3dd6f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 10 Jun 2013 17:48:13 +0200 Subject: [PATCH] Fix a BC breach related to bug #53437 days and special_amount properties are exported as int again --- ext/date/php_date.c | 15 ++------ ext/date/tests/bug45682.phpt | 4 +- ext/date/tests/bug49778.phpt | 2 +- ext/date/tests/bug52113.phpt | 26 ++++++------- ext/date/tests/bug52808.phpt | 12 +++--- ext/date/tests/bug53437.phpt | 6 +-- ext/date/tests/bug53437_var2.phpt | 6 +-- ext/date/tests/bug53437_var3.phpt | 4 +- ext/date/tests/bug53437_var4.phpt | 62 +++++++++++++++++++++++++++++++ ext/date/tests/bug60774.phpt | 2 +- ext/date/tests/date_diff1.phpt | 4 +- 11 files changed, 98 insertions(+), 45 deletions(-) create mode 100644 ext/date/tests/bug53437_var4.phpt diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d09d254c17..28ac86b119 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 094c7fdf45..ea8fa94706 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 cc52a23b25..2062d69168 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 862e92e961..f4730c6a44 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 e3b38bb5ff..1f0fc84cd7 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 7a282ab6c2..2ea091453f 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 70565960ef..50aebda57c 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 06f68df61f..da7d0bd396 100644 --- a/ext/date/tests/bug53437_var3.phpt +++ b/ext/date/tests/bug53437_var3.phpt @@ -32,11 +32,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 0000000000..03b0a54c3e --- /dev/null +++ b/ext/date/tests/bug53437_var4.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #53437 (Check that var_dump out is the same using the whole object or it's single properties), variation 4 +--FILE-- +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/bug60774.phpt b/ext/date/tests/bug60774.phpt index 865928dd83..7045cd7781 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 3f3d1da7a8..a908cdba75 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"]=> -- 2.40.0