php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70153 \DateInterval incorrectly unserialized
Submitted: 2015-07-27 13:26 UTC Modified: 2017-10-24 05:24 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: php dot net at artursvonda dot lv Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.6.1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot net at artursvonda dot lv
New email:
PHP Version: OS:

 

 [2015-07-27 13:26 UTC] php dot net at artursvonda dot lv
Description:
------------
When unserialising DateInterval, boolean fields are stored as integers.

http://3v4l.org/RkMGa

Test script:
---------------
$interval = \DateInterval::createFromDateString('+1 month');
var_dump($interval->days === false);
var_dump(unserialize(serialize($interval))->days === false);

Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(false)

Patches

dateinterval-unserialize (last revision 2015-07-27 14:27 UTC) by cmb@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-27 14:27 UTC] cmb@php.net
The following patch has been added/updated:

Patch Name: dateinterval-unserialize
Revision:   1438007244
URL:        https://bugs.php.net/patch-display.php?bug=70153&patch=dateinterval-unserialize&revision=1438007244
 [2015-07-27 14:28 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Operating System: Ubuntu +Operating System: * -PHP Version: Irrelevant +PHP Version: 5.6.1 -Assigned To: +Assigned To: derick
 [2015-07-27 14:28 UTC] cmb@php.net
I can confirm the behavior. It seems there is a special handling
missing for the days property, so that bool(false) is converted to
the proper internal representation -99999.

Derick, could you please have a look at the attached patch
"dateinterval-unserialize". I think that would solve the issue.
 [2017-10-24 05:24 UTC] kalle@php.net
-Status: Analyzed +Status: Assigned
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC