Skip to content

Commit 932586c

Browse files
committed
Fixed bug GH-9431: DateTime::getLastErrors() not returning false when no errors/warnings
For PHP 8.2 and later only.
1 parent 218da70 commit 932586c

File tree

4 files changed

+11
-51
lines changed

4 files changed

+11
-51
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug GH-9285 (Traits cannot be used in readonly classes).
1818
(kocsismate)
1919

20+
- Date:
21+
. Fixed bug GH-9431 (DateTime::getLastErrors() not returning false when no
22+
errors/warnings). (Derick)
23+
2024
- Opcache:
2125
. Fixed bug GH-9371 (Crash with JIT on mac arm64)
2226
(jdp1024/David Carlier)

ext/date/php_date.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,11 @@ static void update_errors_warnings(timelib_error_container *last_errors) /* {{{
22692269
timelib_error_container_dtor(DATEG(last_errors));
22702270
DATEG(last_errors) = NULL;
22712271
}
2272-
DATEG(last_errors) = last_errors;
2272+
if (last_errors->warning_count || last_errors->error_count) {
2273+
DATEG(last_errors) = last_errors;
2274+
} else {
2275+
timelib_error_container_dtor(last_errors);
2276+
}
22732277
} /* }}} */
22742278

22752279
static void php_date_set_time_fraction(timelib_time *time, int microseconds)

ext/date/tests/bug51866.phpt

+2-24
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,7 @@ object(DateTime)#%d (3) {
105105
["timezone"]=>
106106
string(%d) "%s"
107107
}
108-
array(4) {
109-
["warning_count"]=>
110-
int(0)
111-
["warnings"]=>
112-
array(0) {
113-
}
114-
["error_count"]=>
115-
int(0)
116-
["errors"]=>
117-
array(0) {
118-
}
119-
}
108+
bool(false)
120109

121110

122111
string(7) "Y-m-d +"
@@ -148,15 +137,4 @@ object(DateTime)#%d (3) {
148137
["timezone"]=>
149138
string(%d) "%s"
150139
}
151-
array(4) {
152-
["warning_count"]=>
153-
int(0)
154-
["warnings"]=>
155-
array(0) {
156-
}
157-
["error_count"]=>
158-
int(0)
159-
["errors"]=>
160-
array(0) {
161-
}
162-
}
140+
bool(false)

ext/date/tests/date-lenient-create.phpt

-26
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,11 @@ DateTime Object
113113
[timezone_type] => 3
114114
[timezone] => UTC
115115
)
116-
Array
117-
(
118-
[warning_count] => 0
119-
[warnings] => Array
120-
(
121-
)
122-
123-
[error_count] => 0
124-
[errors] => Array
125-
(
126-
)
127-
128-
)
129116
==
130117
DateTime Object
131118
(
132119
[date] => 2004-06-08 00:00:00.000000
133120
[timezone_type] => 3
134121
[timezone] => UTC
135122
)
136-
Array
137-
(
138-
[warning_count] => 0
139-
[warnings] => Array
140-
(
141-
)
142-
143-
[error_count] => 0
144-
[errors] => Array
145-
(
146-
)
147-
148-
)
149123
==

0 commit comments

Comments
 (0)