Page MenuHomePhabricator

LocalSettings.php is missing page gives deprecation warnings
Closed, ResolvedPublicBUG REPORT

Description

If you go to install mediawiki, and have error reporting enabled, the first page you hit (LocalSettings.php is missing) gives the following warnings:

Deprecated: Premature access to service container [Called from TemplateParser::getTemplate in /var/www/html/w/includes/TemplateParser.php at line 115] in /var/www/html/w/includes/debug/MWDebug.php on line 377

Deprecated: Premature access to service 'HookContainer' [Called from MediaWiki\MediaWikiServices::getInstance in /var/www/html/w/includes/MediaWikiServices.php at line 282] in /var/www/html/w/includes/debug/MWDebug.php on line 377

Deprecated: Premature access to service 'ObjectFactory' [Called from Wikimedia\Services\ServiceContainer::{closure} in /var/www/html/w/includes/ServiceWiring.php at line 687] in /var/www/html/w/includes/debug/MWDebug.php on line 377

Deprecated: Premature access to service 'MainConfig' [Called from TemplateParser::getTemplate in /var/www/html/w/includes/TemplateParser.php at line 115] in /var/www/html/w/includes/debug/MWDebug.php on line 377

Deprecated: Premature access to service 'ConfigFactory' [Called from Wikimedia\Services\ServiceContainer::{closure} in /var/www/html/w/includes/ServiceWiring.php at line 906] in /var/www/html/w/includes/debug/MWDebug.php on line 377

Deprecated: Premature access to service 'BootstrapConfig' [Called from Wikimedia\Services\ServiceContainer::{closure} in /var/www/html/w/includes/ServiceWiring.php at line 392] in /var/www/html/w/includes/debug/MWDebug.php on line 377

This is a pretty bad user experience. We should try and fix this before releasing 1.38.

Event Timeline

This feels dupe-y...

T273261: Premature access to service container but that's not specifically about the installer

Is this a new warning in 1.38? If not, I don't think this should be a blocker.

How do you enable error reporting if there is now LocalSettings.php?
I'd like to try and reproduce.

The problem is that TemplateParser::getTemplate wants to access the config, to get the secret key for use in caching:

$config = MediaWikiServices::getInstance()->getMainConfig();
$secretKey = $config->get( 'SecretKey' );

That was introduced in 2016 by this commiet https://gerrit.wikimedia.org/r/c/mediawiki/core/+/323083 (which I approved at the time).

I'll make a patch for 1.39. I don't think it needs fixing in 1.38, since it ghas been around for years without anyone noticing. But backporting is trivial enough if anyone feels like it.

Change 779916 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779916

Change 779916 merged by jenkins-bot:

[mediawiki/core@master] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779916

I'll make a patch for 1.39. I don't think it needs fixing in 1.38, since it ghas been around for years without anyone noticing. But backporting is trivial enough if anyone feels like it.

It feels dejavu. I feel like TemplateParser has caused similar problems elsewhere, but couldn't find a task offhand...

Change 779872 had a related patch set uploaded (by Reedy; author: Daniel Kinzler):

[mediawiki/core@REL1_38] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779872

Change 779873 had a related patch set uploaded (by Reedy; author: Daniel Kinzler):

[mediawiki/core@REL1_37] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779873

Change 779874 had a related patch set uploaded (by Reedy; author: Daniel Kinzler):

[mediawiki/core@REL1_36] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779874

Change 779875 had a related patch set uploaded (by Reedy; author: Daniel Kinzler):

[mediawiki/core@REL1_35] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779875

Reedy renamed this task from LocalSettings.php is missing page gives deprecation warnings in REL1_38, and master to LocalSettings.php is missing page gives deprecation warnings.Apr 13 2022, 7:34 PM

Change 779875 merged by jenkins-bot:

[mediawiki/core@REL1_35] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779875

Change 779873 merged by jenkins-bot:

[mediawiki/core@REL1_37] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779873

Change 779874 merged by jenkins-bot:

[mediawiki/core@REL1_36] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779874

Change 779872 merged by jenkins-bot:

[mediawiki/core@REL1_38] TemplateParser: avoid warnings when called by NoLocalSettings.

https://gerrit.wikimedia.org/r/779872

Reedy assigned this task to daniel.