Bug #78590 [NEW]: DatePeriod 0 Recurrences Throws Exception

From: Date: Mon, 23 Sep 2019 15:35:31 +0000
Subject: Bug #78590 [NEW]: DatePeriod 0 Recurrences Throws Exception
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222893@lists.php.net to get a copy of this message
From:             will dot baumbach at iselinc dot com
Operating system: Linux
PHP version:      7.2.22
Package:          Date/time related
Bug Type:         Bug
Bug description:DatePeriod 0 Recurrences Throws Exception

Description:
------------
---
From manual page: https://php.net/dateperiod.construct
---

As of 7.2.19+, 7.3.6+ and 7.4.0+ the DatePeriod constructor recurrences
argument, no longer accepts 0. Instead an exception is thrown.

This was an undocumented change in the 7.2.19 change log and on the
DatePeriod documentation page.

Fatal error: Uncaught Exception: DatePeriod::__construct(): The
recurrence count '0' is invalid. Needs to be > 0 in /in/vjVTF:6
Stack trace:
#0 /in/vjVTF(6): DatePeriod->__construct(Object(DateTimeImmutable),
Object(DateInterval), 0)



Test script:
---------------
new \DatePeriod(new \DateTimeImmutable(), new \DateInterval('P1D'), 0);


https://3v4l.org/vjVTF




-- 
Edit bug report at https://bugs.php.net/bug.php?id=78590&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78590&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78590&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78590&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78590&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78590&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78590&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78590&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78590&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78590&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78590&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78590&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78590&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78590&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78590&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78590&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78590&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78590&r=mysqlcfg


Thread (13 messages)

« previous php.bugs (#222893) next »