Bug #61173 [Opn->Fbk]: Unable to detect error from finfo constructor
| From: | cataphract@php.net | Date: | Fri, 24 Feb 2012 08:34:49 +0000 |
| Subject: | Bug #61173 [Opn->Fbk]: Unable to detect error from finfo constructor | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167783@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61173&edit=1
ID: 61173
Updated by: cataphract@php.net
Reported by: vrana@php.net
Summary: Unable to detect error from finfo constructor
-Status: Open
+Status: Feedback
Type: Bug
Package: Filesystem function related
Operating System: Irrelevant
PHP Version: 5.4.0RC8
Block user comment: N
Private report: N
New Comment:
The manual suggests new should give NULL in case of error: http://php.net/finfo_open . Why do you expect the exception? In
any case, there's of course a bug because new is giving an object.
Previous Comments:
------------------------------------------------------------------------
[2012-02-23 20:45:57] vrana@php.net
Description:
------------
There is currently no way to detect error in finfo::__construct() other than defining own
set_error_handler(). It should throw an exception in case of an error.
new finfo() always creates the object but this object is unusable if constructor doesn't
succeed.
Test script:
---------------
$finfo = null;
try {
$finfo = new finfo(1, '', false);
} catch (Exception $e) {
echo "Error creating finfo.\n";
}
var_dump($finfo);
Expected result:
----------------
Error creating finfo.
NULL
Actual result:
--------------
object(finfo)#1 (0) {
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61173&edit=1