Bug #78590 [Opn->Ver]: DatePeriod 0 Recurrences Throws Exception since 7.2.19

From: Date: Mon, 23 Sep 2019 15:44:48 +0000
Subject: Bug #78590 [Opn->Ver]: DatePeriod 0 Recurrences Throws Exception since 7.2.19
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222894@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78590&edit=1

 ID:                 78590
 Updated by:         requinix@php.net
 Reported by:        will dot baumbach at iselinc dot com
-Summary:            DatePeriod 0 Recurrences Throws Exception
+Summary:            DatePeriod 0 Recurrences Throws Exception since
                     7.2.19
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        7.2.22
 Block user comment: N
 Private report:     N

 New Comment:

See bug #77909

https://github.com/php/php-src/commit/7b1a4e24008f34a76c343ece735953ad5124e09f
Looks like the commit put the NEWS entry in the wrong section. Could explain why it's missing
from the docs.

I'm leaving this as a regular non-doc bug because NEWS should probably be fixed.


Previous Comments:
------------------------------------------------------------------------
[2019-09-23 15:35:31] will dot baumbach at iselinc dot com

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 this bug report at https://bugs.php.net/bug.php?id=78590&edit=1


Thread (13 messages)

« previous php.bugs (#222894) next »