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:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: php dot net at artursvonda dot lv Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.1 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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)

Pull Requests

Pull requests:

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
 [2019-09-06 15:40 UTC] yakuninm at gmail dot com
The following pull request has been associated:

Patch Name: Fix #70153 \DateInterval incorrectly unserialized
On GitHub:  https://github.com/php/php-src/pull/4687
Patch:      https://github.com/php/php-src/pull/4687.patch
 [2019-10-18 13:34 UTC] cmb@php.net
Automatic comment on behalf of m.yakunin@8bitgroup.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d2cde0bfd39422be3af49f6513a0a5358ef7cf63
Log: Fix #70153 \DateInterval incorrectly unserialized
 [2019-10-18 13:34 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC