Page MenuHomePhabricator

integration/phpunit has an older composer/ClassLoader.php that doesn't understand psr-4
Closed, ResolvedPublic


The wikimedia/iegreview project is using a PSR-4 autoloading scheme (just like PSR-0 except you don't have to have a bunch of empty directories in your path to define the full namespace).

The phpunit job for this repository is failing with this error:

PHP Fatal error: Call to undefined method Composer\Autoload\ClassLoader::setPsr4() in /srv/ssd/jenkins-slave/workspace/wikimedia-iegreview-phpunit/vendor/composer/autoload_real.php on line 33
PHP Stack trace:
PHP 1. {main}() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:63
PHP 3. PHPUnit_TextUI_Command->run() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_Command->handleArguments() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:138
PHP 5. PHPUnit_TextUI_Command->handleBootstrap() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:606
PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:778
PHP 7. PHPUnit_Util_Fileloader::load() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:76
PHP 8. include_once() /srv/deployment/integration/phpunit/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:92
PHP 9. require() /srv/ssd/jenkins-slave/workspace/wikimedia-iegreview-phpunit/tests/bootstrap.php:24
PHP 10. ComposerAutoloaderInit219a9bfa76f2ac9b53cf75ea98d99ffa::getLoader() /srv/ssd/jenkins-slave/workspace/wikimedia-iegreview-phpunit/vendor/autoload.php:7

After a lot of head scratching I figured out that this is caused by the vendor/composer/ClassLoader.php that is loaded from the integration/phpunit project to run phpunit. This older version of the \Composer\Autoload\ClassLoader class shadows the newer version present in wikimedia/iegreview/vendor/composer/ClassLoader.php.

The fix for this should be as easy as regenerating the classloader for the integration/phpunit project using a newer version of Composer that supports PSR-4 autoloaders.

Version: wmf-deployment
Severity: normal



Related Objects

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:44 AM
bzimport set Reference to bz71629.
bd808 created this task.Oct 3 2014, 9:52 PM

gerritadmin wrote:

Change 164683 had a related patch set uploaded by BryanDavis:
Update to phpunit 3.7.37 and PSR-4 classloader

gerritadmin wrote:

Change 164687 had a related patch set uploaded by BryanDavis:
Regenerate autoloader

gerritadmin wrote:

Change 164687 merged by BryanDavis:
Regenerate autoloader

bd808 added a comment.Oct 3 2014, 11:28 PM

Tests needing PSR-4 autoloader are passing now. I left a pending patch for Antoine to look at that would upgrade phpunit to the latest 3.7.x version.