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:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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: Tue Aug 29 15:01:52 2017 UTC