Req #50020 [Fbk->NoF]: DateInterval:createDateFromString() silently fails

From: Date: Tue, 30 Dec 2014 10:41:36 +0000
Subject: Req #50020 [Fbk->NoF]: DateInterval:createDateFromString() silently fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189395@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50020&edit=1 ID: 50020 Updated by: php-bugs@lists.php.net Reported by: jennifer dot kimball at nrc dot ca Summary: DateInterval:createDateFromString() silently fails -Status: Feedback +Status: No Feedback Type: Feature/Change Request Package: Date/time related Operating System: Solaris 10 PHP Version: 5.3.0 Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2014-04-24 10:13:02] datibbaw@php.net Sorry, I somehow missed the comment thread (was looking at the wrong tab) ;-) ------------------------------------------------------------------------ [2014-04-24 10:09:39] datibbaw@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Couldn't reproduce the memory issue from 5.3.0 onwards: http://3v4l.org/kPMor ------------------------------------------------------------------------ [2009-10-30 18:33:08] jennifer dot kimball at nrc dot ca The snapshot fixes the memory problem for me. But there is still no way to easily tell if a DateInterval size is zero or if there were errors creating the DateInterval. ------------------------------------------------------------------------ [2009-10-27 22:31:45] jani@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Works just fine for me. ------------------------------------------------------------------------ [2009-10-27 17:35:39] jennifer dot kimball at nrc dot ca Description: ------------ Documentation of DateInterval:createDateFromString() does not state what happens when the function fails. So far as I can tell, it seems to produce an empty DateInterval object. If an empty object is the expected behaviour then it should be documented. And more importantly, there should be an easy way to test if the object is empty. Given that creating a DatePeriod using an empty DateInterval consumes all the memory available to a session, it seems to me that allowing empty DateIntervals is a design flaw. Reproduce code: --------------- --- From manual page: dateinterval.createfromdatestring#Return Values --- $i=DateInterval::createFromDateString('P1D');//expected to fail $d1=date_create('2009-10-27'); $d2=date_create('2009-11-15'); $p=new DatePeriod($d1,$i,$d2); //PHP times out Expected result: ---------------- expect error at line $i=DateInterval::createFromDateString('P1D') Actual result: -------------- Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 72 bytes) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50020&edit=1

« previous php.bugs (#189395) next »