Bug #81500 [Asn]: Interval serialization regression since 7.3.14 / 7.4.2

From: Date: Tue, 12 Oct 2021 09:36:45 +0000
Subject: Bug #81500 [Asn]: Interval serialization regression since 7.3.14 / 7.4.2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237153@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81500&edit=1

 ID:                 81500
 Updated by:         cmb@php.net
 Reported by:        kylekatarnls at gmail dot com
 Summary:            Interval serialization regression since 7.3.14 /
                     7.4.2
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 PHP Version:        8.0.11
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Well, actually the *un*serialization is correct, because negative
values of DateInterval::$f are not supposed to be supported.


Previous Comments:
------------------------------------------------------------------------
[2021-10-06 08:24:15] cmb@php.net

That's caused by the fix for bug #79015.

------------------------------------------------------------------------
[2021-10-04 11:28:53] kylekatarnls at gmail dot com

Description:
------------
When DateInterval f property = -0.000001, it's properly restored as float(-1.0E-6) after
unserialize(serialize()) until PHP 7.3.13 / 7.4.1 but since 7.3.14 / 7.4.2 and all >= 8, it
becomes int(-1)

See https://3v4l.org/t5N4d

Test script:
---------------
$interval = new DateInterval('PT1S');
$interval->f = -0.000001;

var_dump($interval->s, $interval->f);

echo "\n";
$interval = unserialize(serialize($interval));

var_dump($interval->s, $interval->f);

Expected result:
----------------
int(1)
float(-1.0E-6)

int(1)
float(-1.0E-6)

Actual result:
--------------
int(1)
float(-1.0E-6)

int(1)
int(-1)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81500&edit=1


Thread (8 messages)

« previous php.bugs (#237153) next »