Edit report at http://bugs.php.net/bug.php?id=50242&edit=1
ID: 50242 Updated by: [email protected] Reported by: jussi at growvc dot com Summary: Creating a DateTime object causes error_get_last() return value to reset -Status: Assigned +Status: Bogus Type: Bug Package: Date/time related Operating System: * PHP Version: 5.2 Assigned To: derick New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is not a bug, this is how PHP's internal error handling works (in 5.2). Errors are only kept internally until some mechanism resets it. The data is only guaranteed to be there *directly* after an error has been created. In PHP 5.3 and up, conversion from warnings/errors to exceptions is done differently so therefore it works better there. Previous Comments: ------------------------------------------------------------------------ [2009-11-20 18:00:09] [email protected] Happens only in PHP_5_2 branch. ------------------------------------------------------------------------ [2009-11-20 13:16:28] jussi at growvc dot com Description: ------------ It seems that calling the DateTime class constructor causes an error accumulated in error_get_last() to be cleared. I am using a 64bit Linux (Ubuntu 9.10) with PHP 5.2.11 built by dotdeb.org (unfortunately phpinfo() of their version doesn't give up configure options). The problem reproduces with a default php.ini, both as Apache module and on CLI. I was also able do reproduce this on another system with another PHP version (5.2.9, also a dotdeb build). Reproduce code: --------------- @trigger_error('foo'); echo (is_array(error_get_last())?'Error':'No error') . "\n"; $dt = new DateTime(); echo (is_array(error_get_last())?'Error':'No error') . "\n"; Expected result: ---------------- Error Error Actual result: -------------- Error No error ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=50242&edit=1
