php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65443 class_exists with $autoload=true raising fatal error
Submitted: 2013-08-13 19:02 UTC Modified: 2013-10-15 11:54 UTC
From: pieczar92 at interia dot pl Assigned:
Status: No Feedback Package: PHP options/info functions
PHP Version: 5.4.17 OS: Windows 8
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: pieczar92 at interia dot pl
New email:
PHP Version: OS:

 

 [2013-08-13 19:02 UTC] pieczar92 at interia dot pl
Description:
------------
Welcome.

My report is related to the function:
bool class_exists (string $ class_name [, bool $ autoload = true])

Namely, I have noticed that if the result of the function returns false, the 
script crashes mistake, because after all, the script tries to load a non-
existent class. Problem solved by changing the parameter $ autoload to false.

I believe that the $ autoload should be taken into account only if the result of 
the function will amount to true.

I'm sorry for syntax errors. My text was translated Google tools - translation.

Regards,
Kamil Piechaczek

Test script:
---------------
if( class_exists('finfo', false) ) {
    $fInfo = new finfo(FILEINFO_MIME);
    $gravatarImageMime = $fInfo->file($gravatarURL, FILEINFO_MIME_TYPE);
} else {
    $gravatarImage = getimagesize($gravatarURL);
    $gravatarImageMime = $gravatarImage['mime'];
}

Expected result:
----------------
Variable $gravatarImageMime should has type mime of file.

Actual result:
--------------
White screen (autoload can't find file)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-13 19:48 UTC] requinix@php.net
-Summary: PHP Version: 5.4.16 +Summary: class_exists with $autoload=true raising fatal error
 [2013-08-13 19:48 UTC] requinix@php.net
Ticket renamed.

Test scripts need to be stand-alone and executable with a simple copy and paste on our part. What you've posted requires a $gravatarURL and, to 
reproduce your results, an autoloader.

You are using an autoloader, correct? Yours is deriving a filename and immediately require or require_once-ing it. That is incorrect: it must 
check if the file even exists first.

Make that change to your autoloader and use $autoload=true in your call to class_exists(). If that does not fix the problem then please post a 
COMPLETE test script that can be run by itself without using any undefined variables or external autoloaders.
 [2013-08-13 20:43 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC