-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
While it may not be desired, `DateInterval::$f` supports negative values, at least with regard to calculations. We still need to guard from assigning double values which are out of range for signed 64bit integers (which would be undefined behavior). zend_dval_to_lval() does this by returning `0` instead of triggering UB. This way we can avoid setting the invalid marker, which doesn't work as expected anyway. We must not do that only for unserialization, but also when the property is set in the first place. We need to adapt some of the existing tests wrt. this behavior. In particular, we check for an arbitrary value in bug79015.phpt, to cater to differences between 32bit and 64bit architectures. Closes GH-7575.
- Loading branch information
Showing
8 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,6 @@ object(DateInterval)#%d (16) { | |
["have_special_relative"]=> | ||
int(0) | ||
["f"]=> | ||
float(-1) | ||
float(0) | ||
} | ||
==DONE== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,6 @@ object(DateInterval)#%d (16) { | |
["have_special_relative"]=> | ||
int(0) | ||
["f"]=> | ||
float(-1) | ||
float(0) | ||
} | ||
==DONE== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
Bug #81500 (Interval serialization regression since 7.3.14 / 7.4.2) | ||
--FILE-- | ||
<?php | ||
$interval = new DateInterval('PT1S'); | ||
$interval->f = -0.000001; | ||
var_dump($interval->s, $interval->f); | ||
|
||
$interval = unserialize(serialize($interval)); | ||
var_dump($interval->s, $interval->f); | ||
?> | ||
--EXPECT-- | ||
int(1) | ||
float(-1.0E-6) | ||
int(1) | ||
float(-1.0E-6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ array(2) { | |
["s"]=> | ||
int(-1) | ||
["f"]=> | ||
float(-1) | ||
float(0) | ||
["weekday"]=> | ||
int(-1) | ||
["weekday_behavior"]=> | ||
|