php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75182 Should DateTimeImmutable/DateTime throw a exception
Submitted: 2017-09-11 09:28 UTC Modified: -
From: nyamsprod at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: Irrelevant 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: nyamsprod at gmail dot com
New email:
PHP Version: OS:

 

 [2017-09-11 09:28 UTC] nyamsprod at gmail dot com
Description:
------------
in PHP7.1+ DateInterval can take the number of microseconds, as a fraction of a second with the DateInterval::f public property.

If DateInterval::f is set with a value greater than 1, DateInterval accepts it without warning. If we modify a DateTimeInterface object with this "invalid" DateInterval, a invalid DateTimeInterface object is returned.

see https://3v4l.org/PcEMi


Test script:
---------------
$interval = new DateInterval('PT1S');
$interval->f = 500000;  // excepted an Exception
var_dump(date_create_immutable('2017-03-15')->add($interval));
// expected an OverflowException or a valid DateTimeInterface 

returns an Invalid DateTimeInterface

object(DateTimeImmutable)#3 (3) {
 ["date"]=> string(31) "2017-03-15 00:00:03.-2147483648"
 ["timezone_type"]=> int(3)
 ["timezone"]=> string(16) "Europe/Amsterdam"
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC