php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77909 DatePeriod::__construct accept invalid recurrences count
Submitted: 2019-04-16 15:25 UTC Modified: -
From: nyamsprod at gmail dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2019-04-16 15:25 UTC] nyamsprod at gmail dot com
Description:
------------
Currently when instantiating a DatePeriod object with the ISO Interval notation an exception is thrown if the recurrence count value is lesser than 1.

But when using the alternate constructor no exception is thrown. This lead to the recurrence count being lesser than 1 which should not be possible.

Test script:
---------------
$date = new DatePeriod(
    new DateTime('2012-07-01T00:00:00Z'),
    new DateInterval('P7D'),
    0
);

Expected result:
----------------
An exception should be thrown instead an invalid DatePeriod is returned.


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-16 15:27 UTC]
The following pull request has been associated:

Patch Name: Fixed bug #77909: DatePeriod::__construct() with invalid recurrence count value
On GitHub:  https://github.com/php/php-src/pull/3987
Patch:      https://github.com/php/php-src/pull/3987.patch
 [2019-04-17 08:40 UTC] derick@php.net
Automatic comment on behalf of nyamsprod@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7b1a4e24008f34a76c343ece735953ad5124e09f
Log: Fixed bug #77909: DatePeriod::__construct() with invalid recurrence count value
 [2019-04-17 08:40 UTC] derick@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC