php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48173 file_exists() fails to find in include_path when using __autoload
Submitted: 2009-05-06 23:54 UTC Modified: 2009-05-07 07:58 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kevinpeno at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.9 OS: Windows Server 2008
Private report: No CVE-ID:
 [2009-05-06 23:54 UTC] kevinpeno at gmail dot com
Description:
------------
Using file_exists fails to find valid files within include_path when using an __autoload. Removing file_exists() the required file is found and loaded.

Safe mode is not enabled.

Reproduce code:
---------------
<?php
function __autoload( $classname )
{
	$file = str_replace( '_', DIRECTORY_SEPARATOR, $classname ).'.php';

	if( file_exists( $file ) )
	{
		require( $file );
		return true;
	}
	else
	{
		return FALSE;
	}
}
# Sets include path to the current directory just for easy testing.
set_include_path( realpath( dirname(__FILE__) ).DIRECTORY_SEPARATOR.PATH_SEPARATOR.get_include_path() );

$test = new Prefix_ClassName();
?>

Expected result:
----------------
File included class initialized.

Actual result:
--------------
Fatal error: Class 'Prefix_ClassName' not found.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-06 23:56 UTC] kevinpeno at gmail dot com
I'm using windows build 5.2.9-2 NTS. This option was not selectable.
 [2009-05-07 07:58 UTC] jani@php.net
file_exists() doesn't care about include_path.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 19:02:26 2014 UTC