File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ PHP NEWS
18
18
- Core:
19
19
. Fixed strerror_r detection at configuration time. (Kévin Dunglas)
20
20
21
+ - Date:
22
+ . Fixed bug GH-11416: Crash with DatePeriod when uninitialised objects
23
+ are passed in. (Derick)
24
+
21
25
- DOM:
22
26
. Fix DOMEntity field getter bugs. (nielsdos)
23
27
. Fix incorrect attribute existence check in DOMElement::setAttributeNodeNS.
Original file line number Diff line number Diff line change @@ -4956,6 +4956,12 @@ PHP_METHOD(DatePeriod, __construct)
4956
4956
RETURN_THROWS ();
4957
4957
}
4958
4958
} else {
4959
+ /* check initialisation */
4960
+ DATE_CHECK_INITIALIZED (Z_PHPDATE_P (start )-> time , DateTimeInterface );
4961
+ if (end ) {
4962
+ DATE_CHECK_INITIALIZED (Z_PHPDATE_P (end )-> time , DateTimeInterface );
4963
+ }
4964
+
4959
4965
/* init */
4960
4966
php_interval_obj * intobj = Z_PHPINTERVAL_P (interval );
4961
4967
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug GH-11416: Crash with DatePeriod when uninitialised objects are passed in
3
+ --INI--
4
+ date.timezone=UTC
5
+ --FILE--
6
+ <?php
7
+ $ now = new DateTimeImmutable ();
8
+
9
+ $ date = (new ReflectionClass (DateTime::class))->newInstanceWithoutConstructor ();
10
+ try {
11
+ new DatePeriod ($ date , new DateInterval ('P1D ' ), 2 );
12
+ } catch (Error $ e ) {
13
+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
14
+ }
15
+
16
+ $ date = (new ReflectionClass (DateTime::class))->newInstanceWithoutConstructor ();
17
+ try {
18
+ new DatePeriod ($ now , new DateInterval ('P1D ' ), $ date );
19
+ } catch (Error $ e ) {
20
+ echo get_class ($ e ), ': ' , $ e ->getMessage (), "\n" ;
21
+ }
22
+
23
+ echo "OK \n" ;
24
+ ?>
25
+ --EXPECT--
26
+ Error: The DateTimeInterface object has not been correctly initialized by its constructor
27
+ Error: The DateTimeInterface object has not been correctly initialized by its constructor
28
+ OK
You can’t perform that action at this time.
0 commit comments