TestSetup: avoid "premature access to service container"
TestSetup uses CheckComposerLockUpToDate to check if the composer dependencies are up to date. CheckComposerLockUpToDate uses wfMessage to generate localized output, which will fail since TestSetup runs before MediaWikiServices is initialized. Change-Id: I995a1cb01abcde7ebe2282b82d33cb50c31587a6
This commit is contained in:
parent
5fc28ecc5b
commit
d5d585b9b2
1 changed files with 9 additions and 4 deletions
|
|
@ -44,10 +44,15 @@ class CheckComposerLockUpToDate extends Maintenance {
|
|||
// We couldn't find any out-of-date dependencies, so assume everything is ok!
|
||||
$this->output( "Your composer.lock file is up to date with current dependencies!\n" );
|
||||
} else {
|
||||
foreach ( $result->getErrors() as $error ) {
|
||||
$this->error(
|
||||
wfMessage( $error['message'], ...$error['params'] )->inLanguage( 'en' )->plain() . "\n"
|
||||
);
|
||||
// NOTE: wfMessage will fail if MediaWikiServices is not yet initialized.
|
||||
// This can happen when this class is called directly from bootstrap code,
|
||||
// e.g. by TestSetup. We get around this by having testSetup use quiet mode.
|
||||
if ( !$this->isQuiet() ) {
|
||||
foreach ( $result->getErrors() as $error ) {
|
||||
$this->error(
|
||||
wfMessage( $error['message'], ...$error['params'] )->inLanguage( 'en' )->plain() . "\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->fatalError(
|
||||
'Error: your composer.lock file is not up to date. ' .
|
||||
|
|
|
|||
Loading…
Reference in a new issue