A recent change to cms.php has broken bootstrapping a Joomla app under certain circumstances.
e1cfdc0#diff-fbf0c47a548d70d6a89b2493eb556dbc
The problem, as far as I've been able to tell, is this line:
$loader = require_once JPATH_LIBRARIES . '/vendor/autoload.php';
This assumes that the composer autoloader file has not been required already. The way require_once works is that if a file is required/included a second time that it will return 1 instead of the file. This means the next line:
$loader->unregister();
Fails with an error referencing a non-object, since 1 is not the \Composer\Autoload\ClassLoader object.
PHP Fatal error: Call to a member function unregister() on a non-object in /var/www/451research/joomla/libraries/cms.php on line 34
A common reason that the composer autoloader would already be required is if you are bootstrapping a Joomla app within the context of a command line utility such as phpunit. We run our tests by referencing the phpunit executable in libraries/vendor/bin/phpunit. That executable file includes the composer autoloader.
I don't think it's reasonable to assume that cms.php will be the first to look at the composer autoloader, especially if you use command line libraries. For example, phpunit for tests, symfony console for tasks, or phinx for migrations.
I would provide a PR, but I'm unsure of the best course of action. The way Joomla unregisters the autoloader and then wraps it is unusual, and I'd like to see if there are any opinions on the issue first.
Awesome! Thank you for your help. Should I assume this will be out in 3.4.4?
Should be.
cool thanks again
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-07-06 19:57:10 |
Closed_By | ⇒ | meddy |
Labels |
Added:
?
|
This is corrected already, see c47d015