php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61173 Unable to detect error from finfo constructor
Submitted: 2012-02-23 20:45 UTC Modified: 2012-03-07 07:45 UTC
From: vrana@php.net Assigned: cataphract (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.4.0RC8 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2012-02-23 20:45 UTC] 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) {
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-24 08:34 UTC] cataphract@php.net
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.
 [2012-02-24 08:34 UTC] cataphract@php.net
-Status: Open +Status: Feedback
 [2012-02-24 10:01 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=323472
Log: - Fixed bug #61173 (Unable to detect error from finfo constructor).
- Tidied up NEWS
 [2012-02-24 10:01 UTC] cataphract@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: cataphract
 [2012-02-24 10:01 UTC] cataphract@php.net
I've fixed it with the documented behavior.
 [2012-02-24 10:37 UTC] pajoye@php.net
Please do not close bug when the fix has not been applied to 5.4, so we have a way 
to do not forget it as soon as 5.4-final is out.

Cheers,
 [2012-02-24 10:37 UTC] pajoye@php.net
-Status: Closed +Status: Assigned
 [2012-03-07 07:38 UTC] stas@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&revision=323985
Log: MFH: Fixed bug #61173 (Unable to detect error from finfo constructor).
 [2012-03-07 07:45 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2012-03-07 07:45 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:46 UTC] laruence@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f434afe23640087d4ce60093342b500588588dc4
Log: - Fixed bug #61173 (Unable to detect error from finfo constructor). - Tidied up NEWS
 [2012-07-24 23:37 UTC] rasmus@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f434afe23640087d4ce60093342b500588588dc4
Log: - Fixed bug #61173 (Unable to detect error from finfo constructor). - Tidied up NEWS
 [2013-11-17 09:33 UTC] laruence@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f434afe23640087d4ce60093342b500588588dc4
Log: - Fixed bug #61173 (Unable to detect error from finfo constructor). - Tidied up NEWS
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 19:01:28 2024 UTC