Here is my problem. I have one file (say, func.inc.php) with autoloader function, registered by spl_autoload_register():
function autoloaderFnc($class) {
global $__CONFIG;
$original = $class_name;
$class_name = mb_strtolower ( $class_name );
foreach ( $__CONFIG ['include_dirs'] as $path ) {
if(file_exists ( $__CONFIG ['root'] . $path . $class_name . '.inc.php' )) {
require ($__CONFIG ['root'] . $path . $class_name . '.inc.php');
$classFound = TRUE;
$foundAt = $__CONFIG ['root'] . $path . $class_name . '.inc.php';
break;
}
}
if( $classFound ) {
if ( class_exists( $original ) ) {
return true;
} else {
$backtrace = debug_backtrace();
$error = "PHP User error: Cannot load class <b>$original</b> included at " . $backtrace[1]['file'] . ":" . $backtrace[1]['line'] . " (searching for <i>$class_name.inc.php</i>), but following file was included: $foundAt";
error_log( $error );
return false;
}
} else {
$backtrace = debug_backtrace();
$error = "PHP User error: Cannot find file with class <b>$original</b> included at " . $backtrace[1]['file'] . ":" . $backtrace[1]['line'] . " (searching for <i>$class_name.model.php</i> and <i>$class_name.inc.php</i>) in none of the following include dirs:<br />" . join ( '<br />', $__CONFIG ['include_dirs'] );
error_log( $error );
}
}
spl_autoload_register('autoloaderFnc');
Then I have a second file (show_me_poi.php), calling some class:
POI::doSmth();
Everything seems OK, but sometimes (and only sometimes!) I receive a following error in log:
[error] PHP User error: Cannot load class POI included at /path_to_dir/php/generators/export.generator.php:156 (searching for poi.inc.php), but following file was included: /path_to_dir/php/scripts/php/incs/poi.inc.php
This is weird, because class POI is defined in properly included file! And I repeat, this situation happens only sometime (10 out of 100 I think). What can cause such behaviour? And how can I fix it?
Thanks in advance!