Switch autoloader from '__autoload' magic function name to registering our function with spl_autoload_register(); fixes compat problem with PHPUnit 3.5+ which seems to break the old __autoload

This commit is contained in:
Brion Vibber 2011-01-05 23:27:17 +00:00
parent 946a4ac17b
commit f5650806cc

View File

@ -95,7 +95,11 @@ function _have_config()
return StatusNet::haveConfig();
}
function __autoload($cls)
/**
* Wrapper for class autoloaders.
* This used to be the special function name __autoload(), but that causes bugs with PHPUnit 3.5+
*/
function autoload_sn($cls)
{
if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) {
require_once(INSTALLDIR.'/classes/' . $cls . '.php');
@ -111,6 +115,8 @@ function __autoload($cls)
}
}
spl_autoload_register('autoload_sn');
// XXX: how many of these could be auto-loaded on use?
// XXX: note that these files should not use config options
// at compile time since DB config options are not yet loaded.