Skip to content

Commit 02f3922

Browse files
committed
Fix a BC breach related to bug #53437
days and special_amount properties are exported as int again
1 parent a9d005c commit 02f3922

File tree

11 files changed

+98
-45
lines changed

11 files changed

+98
-45
lines changed

ext/date/php_date.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,18 +2384,9 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
23842384
return props;
23852385
}
23862386

2387-
#define PHP_DATE_INTERVAL_ADD_PROPERTY_I64(n, f) \
2388-
do { \
2389-
char i64_buf[DATE_I64_BUF_LEN]; \
2390-
MAKE_STD_ZVAL(zv); \
2391-
DATE_I64A(intervalobj->diff->f, i64_buf, DATE_I64_BUF_LEN); \
2392-
ZVAL_STRING(zv, i64_buf, 1); \
2393-
zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL); \
2394-
} while(0);
2395-
23962387
#define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
23972388
MAKE_STD_ZVAL(zv); \
2398-
ZVAL_LONG(zv, intervalobj->diff->f); \
2389+
ZVAL_LONG(zv, (long)intervalobj->diff->f); \
23992390
zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zval), NULL);
24002391

24012392
PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);
@@ -2409,14 +2400,14 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
24092400
PHP_DATE_INTERVAL_ADD_PROPERTY("first_last_day_of", first_last_day_of);
24102401
PHP_DATE_INTERVAL_ADD_PROPERTY("invert", invert);
24112402
if (intervalobj->diff->days != -99999) {
2412-
PHP_DATE_INTERVAL_ADD_PROPERTY_I64("days", days);
2403+
PHP_DATE_INTERVAL_ADD_PROPERTY("days", days);
24132404
} else {
24142405
MAKE_STD_ZVAL(zv);
24152406
ZVAL_FALSE(zv);
24162407
zend_hash_update(props, "days", 5, &zv, sizeof(zval), NULL);
24172408
}
24182409
PHP_DATE_INTERVAL_ADD_PROPERTY("special_type", special.type);
2419-
PHP_DATE_INTERVAL_ADD_PROPERTY_I64("special_amount", special.amount);
2410+
PHP_DATE_INTERVAL_ADD_PROPERTY("special_amount", special.amount);
24202411
PHP_DATE_INTERVAL_ADD_PROPERTY("have_weekday_relative", have_weekday_relative);
24212412
PHP_DATE_INTERVAL_ADD_PROPERTY("have_special_relative", have_special_relative);
24222413

ext/date/tests/bug45682.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ object(DateInterval)#%d (15) {
3434
["invert"]=>
3535
int(0)
3636
["days"]=>
37-
string(1) "3"
37+
int(3)
3838
["special_type"]=>
3939
int(0)
4040
["special_amount"]=>
41-
string(1) "0"
41+
int(0)
4242
["have_weekday_relative"]=>
4343
int(0)
4444
["have_special_relative"]=>

ext/date/tests/bug49778.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object(DateInterval)#1 (15) {
3434
["special_type"]=>
3535
int(0)
3636
["special_amount"]=>
37-
string(1) "0"
37+
int(0)
3838
["have_weekday_relative"]=>
3939
int(0)
4040
["have_special_relative"]=>

ext/date/tests/bug52113.phpt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ object(DateInterval)#3 (15) {
5454
["invert"]=>
5555
int(0)
5656
["days"]=>
57-
string(1) "0"
57+
int(0)
5858
["special_type"]=>
5959
int(0)
6060
["special_amount"]=>
61-
string(1) "0"
61+
int(0)
6262
["have_weekday_relative"]=>
6363
int(0)
6464
["have_special_relative"]=>
6565
int(0)
6666
}
67-
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;}"
67+
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;}"
6868
DateInterval::__set_state(array(
6969
'y' => 0,
7070
'm' => 0,
@@ -76,9 +76,9 @@ DateInterval::__set_state(array(
7676
'weekday_behavior' => 0,
7777
'first_last_day_of' => 0,
7878
'invert' => 0,
79-
'days' => '0',
79+
'days' => 0,
8080
'special_type' => 0,
81-
'special_amount' => '0',
81+
'special_amount' => 0,
8282
'have_weekday_relative' => 0,
8383
'have_special_relative' => 0,
8484
))object(DateInterval)#5 (15) {
@@ -103,11 +103,11 @@ DateInterval::__set_state(array(
103103
["invert"]=>
104104
int(0)
105105
["days"]=>
106-
string(1) "0"
106+
int(0)
107107
["special_type"]=>
108108
int(0)
109109
["special_amount"]=>
110-
string(1) "0"
110+
int(0)
111111
["have_weekday_relative"]=>
112112
int(0)
113113
["have_special_relative"]=>
@@ -150,11 +150,11 @@ object(DatePeriod)#6 (6) {
150150
["invert"]=>
151151
int(0)
152152
["days"]=>
153-
string(1) "0"
153+
int(0)
154154
["special_type"]=>
155155
int(0)
156156
["special_amount"]=>
157-
string(1) "0"
157+
int(0)
158158
["have_weekday_relative"]=>
159159
int(0)
160160
["have_special_relative"]=>
@@ -187,11 +187,11 @@ object(DateInterval)#8 (15) {
187187
["invert"]=>
188188
int(1)
189189
["days"]=>
190-
string(4) "2400"
190+
int(2400)
191191
["special_type"]=>
192192
int(0)
193193
["special_amount"]=>
194-
string(2) "-1"
194+
int(-1)
195195
["have_weekday_relative"]=>
196196
int(0)
197197
["have_special_relative"]=>
@@ -234,11 +234,11 @@ object(DatePeriod)#9 (6) {
234234
["invert"]=>
235235
int(0)
236236
["days"]=>
237-
string(1) "0"
237+
int(0)
238238
["special_type"]=>
239239
int(0)
240240
["special_amount"]=>
241-
string(1) "0"
241+
int(0)
242242
["have_weekday_relative"]=>
243243
int(0)
244244
["have_special_relative"]=>

ext/date/tests/bug52808.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ object(DateInterval)#%d (15) {
4747
["invert"]=>
4848
int(1)
4949
["days"]=>
50-
string(3) "437"
50+
int(437)
5151
["special_type"]=>
5252
int(0)
5353
["special_amount"]=>
54-
string(1) "0"
54+
int(0)
5555
["have_weekday_relative"]=>
5656
int(0)
5757
["have_special_relative"]=>
@@ -79,11 +79,11 @@ object(DateInterval)#%d (15) {
7979
["invert"]=>
8080
int(0)
8181
["days"]=>
82-
string(3) "294"
82+
int(294)
8383
["special_type"]=>
8484
int(0)
8585
["special_amount"]=>
86-
string(1) "0"
86+
int(0)
8787
["have_weekday_relative"]=>
8888
int(0)
8989
["have_special_relative"]=>
@@ -111,11 +111,11 @@ object(DateInterval)#%d (15) {
111111
["invert"]=>
112112
int(0)
113113
["days"]=>
114-
string(3) "294"
114+
int(294)
115115
["special_type"]=>
116116
int(0)
117117
["special_amount"]=>
118-
string(1) "0"
118+
int(0)
119119
["have_weekday_relative"]=>
120120
int(0)
121121
["have_special_relative"]=>

ext/date/tests/bug53437.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ object(DatePeriod)#1 (6) {
7777
["special_type"]=>
7878
int(0)
7979
["special_amount"]=>
80-
string(1) "0"
80+
int(0)
8181
["have_weekday_relative"]=>
8282
int(0)
8383
["have_special_relative"]=>
@@ -132,11 +132,11 @@ object(DatePeriod)#5 (6) {
132132
["invert"]=>
133133
int(0)
134134
["days"]=>
135-
string(1) "0"
135+
int(0)
136136
["special_type"]=>
137137
int(0)
138138
["special_amount"]=>
139-
string(1) "0"
139+
int(0)
140140
["have_weekday_relative"]=>
141141
int(0)
142142
["have_special_relative"]=>

ext/date/tests/bug53437_var2.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object(DateInterval)#1 (15) {
3939
["special_type"]=>
4040
int(0)
4141
["special_amount"]=>
42-
string(1) "0"
42+
int(0)
4343
["have_weekday_relative"]=>
4444
int(0)
4545
["have_special_relative"]=>
@@ -67,11 +67,11 @@ object(DateInterval)#2 (15) {
6767
["invert"]=>
6868
int(0)
6969
["days"]=>
70-
string(1) "0"
70+
int(0)
7171
["special_type"]=>
7272
int(0)
7373
["special_amount"]=>
74-
string(1) "0"
74+
int(0)
7575
["have_weekday_relative"]=>
7676
int(0)
7777
["have_special_relative"]=>

ext/date/tests/bug53437_var3.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ object(DateInterval)#1 (15) {
3232
["invert"]=>
3333
int(0)
3434
["days"]=>
35-
string(1) "0"
35+
int(0)
3636
["special_type"]=>
3737
int(0)
3838
["special_amount"]=>
39-
string(19) "9223372036854775807"
39+
int(-1)
4040
["have_weekday_relative"]=>
4141
int(9)
4242
["have_special_relative"]=>

ext/date/tests/bug53437_var4.phpt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
Bug #53437 (Check that var_dump out is the same using the whole object or it's single properties), variation 4
3+
--FILE--
4+
<?php
5+
$dt = new DateTime('2009-10-11');
6+
7+
$df = $dt->diff(new DateTime('2009-10-13'));
8+
9+
var_dump($df,
10+
$df->y,
11+
$df->m,
12+
$df->d,
13+
$df->h,
14+
$df->i,
15+
$df->s,
16+
$df->invert,
17+
$df->days);
18+
19+
?>
20+
==DONE==
21+
--EXPECTF--
22+
object(DateInterval)#%d (15) {
23+
["y"]=>
24+
int(0)
25+
["m"]=>
26+
int(0)
27+
["d"]=>
28+
int(2)
29+
["h"]=>
30+
int(0)
31+
["i"]=>
32+
int(0)
33+
["s"]=>
34+
int(0)
35+
["weekday"]=>
36+
int(0)
37+
["weekday_behavior"]=>
38+
int(0)
39+
["first_last_day_of"]=>
40+
int(0)
41+
["invert"]=>
42+
int(0)
43+
["days"]=>
44+
int(2)
45+
["special_type"]=>
46+
int(0)
47+
["special_amount"]=>
48+
int(0)
49+
["have_weekday_relative"]=>
50+
int(0)
51+
["have_special_relative"]=>
52+
int(0)
53+
}
54+
int(0)
55+
int(0)
56+
int(2)
57+
int(0)
58+
int(0)
59+
int(0)
60+
int(0)
61+
int(2)
62+
==DONE==

ext/date/tests/bug60774.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object(DateInterval)#1 (%d) {
3434
["special_type"]=>
3535
int(0)
3636
["special_amount"]=>
37-
string(1) "0"
37+
int(0)
3838
["have_weekday_relative"]=>
3939
int(0)
4040
["have_special_relative"]=>

ext/date/tests/date_diff1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ object(DateInterval)#3 (15) {
5050
["invert"]=>
5151
int(0)
5252
["days"]=>
53-
string(2) "33"
53+
int(33)
5454
["special_type"]=>
5555
int(0)
5656
["special_amount"]=>
57-
string(1) "0"
57+
int(0)
5858
["have_weekday_relative"]=>
5959
int(0)
6060
["have_special_relative"]=>

0 commit comments

Comments
 (0)