Skip to content
Snippets Groups Projects
Commit 641da416 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Another bugfix: sometimes, very early during execution, a class with...

Another bugfix: sometimes, very early during execution, a class with namespaces might not be autoloaded yet, and if we are asked to load the old class without namespaces, it will fail. Make it load the file corresponding to the class first, and see if it exists then. If not, try to see if it has been migrated to namespaces, and create the alias then.
parent 3424aced
No related branches found
No related tags found
No related merge requests found
......@@ -23,17 +23,26 @@ function temporaryLoader($class)
return; // not a valid class name for old classes
}
// try to load it from the corresponding file
$path = explode('_', $class);
$file = dirname(__FILE__).DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, $path).'.php';
if (file_exists($file)) {
require_once $file;
}
// it exists, so it's not yet migrated to namespaces
if (class_exists($class, false)) {
return;
}
// it didn't exist, try to see if it was migrated to namespaces
$new = join('\\', $path);
if (class_exists($new, false)) {
if (class_exists($new, false)) { // do not try to autoload it if it doesn't exist! It should!
class_alias($new, $class);
SimpleSAML\Logger::warning("The class '$class' is now using namespaces, please use '$new'.");
}
$file = dirname(__FILE__).DIRECTORY_SEPARATOR.join(DIRECTORY_SEPARATOR, $path).'.php';
if (file_exists($file)) {
require_once $file;
}
}
spl_autoload_register("temporaryLoader");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment