Page MenuHomePhabricator

Loading at-ease twice causes fatal error
Closed, ResolvedPublic

Description

Steps to reproduce:

  • set up vagrant with the templatestyles role
  • run update.php

Will result in

Fatal error: Cannot redeclare MediaWiki\suppressWarnings() (previously declared in /vagrant/mediawiki/vendor/mediawiki/at-ease/src/Functions.php:28) in /vagrant/mediawiki/extensions/TemplateStyles/vendor/mediawiki/at-ease/src/MediaWiki/Functions.php on line 30

Call Stack:
    0.0310     240112   1. {main}() /var/www/w/MWScript.php:0
    0.1699     344120   2. require_once('/vagrant/mediawiki/maintenance/update.php') /var/www/w/MWScript.php:95
    0.1756     780176   3. require_once('/vagrant/mediawiki/maintenance/doMaintenance.php') /vagrant/mediawiki/maintenance/update.php:245
    0.1786     973296   4. require_once('/vagrant/mediawiki/includes/Setup.php') /vagrant/mediawiki/maintenance/doMaintenance.php:81
    0.2432    4385904   5. ExtensionRegistry->loadFromQueue() /vagrant/mediawiki/includes/Setup.php:116
    0.2777    6241464   6. ExtensionRegistry->exportExtractedData(???) /vagrant/mediawiki/includes/registration/ExtensionRegistry.php:149
    0.2813    6343120   7. require_once('/vagrant/mediawiki/extensions/TemplateStyles/vendor/autoload.php') /vagrant/mediawiki/includes/registration/ExtensionRegistry.php:334
    0.2823    6360240   8. ComposerAutoloaderInit7924fa37aaa2b2da8800a0c8b2497429::getLoader() /vagrant/mediawiki/extensions/TemplateStyles/vendor/autoload.php:7
    0.2836    6445152   9. composerRequire7924fa37aaa2b2da8800a0c8b2497429(???, ???) /vagrant/mediawiki/extensions/TemplateStyles/vendor/composer/autoload_real.php:56

Both core and TemplateStyles use the at-ease library:

vagrant@templatestyles:/vagrant/mediawiki$ composer why mediawiki/at-ease
mediawiki/core                    dev-master  requires  mediawiki/at-ease (1.1.0)  
oojs/oojs-ui                      v0.25.1     requires  mediawiki/at-ease (1.1.0)  
wikimedia/php-session-serializer  v1.0.4      requires  mediawiki/at-ease (^1.0)   
vagrant@templatestyles:/vagrant/mediawiki/extensions/TemplateStyles$ composer why mediawiki/at-ease
wikimedia/css-sanitizer  v1.0.3  requires  mediawiki/at-ease (1.2.0)

Vagrant runs composer separately for each extension, so both the root vendor and extensions/TemplateStyles/vendor end up with a copy of at-ease.
TemplateStyles uses the load_composer_autoloader extension registry flag.

Event Timeline

at-ease uses global functions and PHP cannot autoload those so it makes sense that Composer would require them and has no way to avoid double-loading. This is somewhat a problem with how we are using Composer by setting up a separate vendor for each extension (which itself is a workaround for Composer having poor update controls).

Legoktm renamed this task from ExtensionRegistry causes fatal error when core and an extension declare the same dependency to Loading at-ease twice causes fatal error.Feb 2 2018, 7:05 AM
Tgr claimed this task.