mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Fix a BC breach related to bug #53437
days and special_amount properties are exported as int again
This commit is contained in:
parent
a9d005c04e
commit
02f3922047
11 changed files with 98 additions and 45 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
62
ext/date/tests/bug53437_var4.phpt
Normal file
62
ext/date/tests/bug53437_var4.phpt
Normal file
|
@ -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--
|
||||
<?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==
|
|
@ -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"]=>
|
||||
|
|
|
@ -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"]=>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue