Page MenuHomePhabricator

"PHP Deprecated: Premature access to service" warnings in 1.36
Open, Needs TriagePublic

Description

Just updated several wikis to 1.36.0 and now I get PHP Deprecated errors, both in my server php log and when I run maintenance scripts. For example, if I run runJobs.php, I get the following:

PHP Deprecated:  Premature access to service container [Called from Hooks::run in /home/xxxxx/xxxxx.ca/includes/Hooks.php at line 135] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'HookContainer' [Called from MediaWiki\MediaWikiServices::getInstance in /home/xxxxx/xxxxx.ca/includes/MediaWikiServices.php at line 252] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'ObjectFactory' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 535] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'StatsdDataFactory' [Called from ObjectCache::newFromParams in /home/xxxxx/xxxxx.ca/includes/objectcache/ObjectCache.php at line 149] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'MainConfig' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 1424] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'ConfigFactory' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 734] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'BootstrapConfig' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 277] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'DBLoadBalancer' [Called from ObjectCache::{closure} in /home/xxxxx/xxxxx.ca/includes/objectcache/ObjectCache.php at line 181] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'DBLoadBalancerFactory' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 383] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'MainWANObjectCache' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 406] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'LocalServerObjectCache' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 411] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376
PHP Deprecated:  Premature access to service 'ConfiguredReadOnlyMode' [Called from Wikimedia\Services\ServiceContainer::{closure} in /home/xxxxx/xxxxx.ca/includes/ServiceWiring.php at line 420] in /home/xxxxx/xxxxx.ca/includes/debug/MWDebug.php on line 376

Job queue is empty.

MediaWiki 1.36.0
PHP 7.4.15 (cgi-fcgi) (same errors on other wikis with PHP 7.4.other
MySQL 5.7.29-log
ICU 60.2

Event Timeline

Aklapper renamed this task from PHP Deprecated errors to "PHP Deprecated: Premature access to service" warnings in 1.36.Jun 10 2021, 8:33 AM
Aklapper added a project: MediaWiki-General.

This adds about 500MB of noise to the logs of my moderately busy wikis in a 2 week period. It persists under 1.36.1, had hoped that would fix it.

Reedy added a subscriber: Reedy.

Just to point out it's not necessarily an issue in MW core itself. It could be an issue with the extensions you have installed. There's no enough information in the reported errors to be able to identify them, or potentially fix them.

You are absolutely right. I finally got back to this, and for me it appears to be Semantic Mediawiki that's causing these. The errors stopped for me when I disabled Semantic Mediawiki. I have raised a ticket with them: https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/5030

I've discovered the deprecated warnings appear when you define the following variables in LocalSettings.php, even if you have no loaded skin or extension:

$wgDBadminuser = 'zzzz;
$wgDBadminpassword = 'zzzz';

Removing them from LocalSettings.php makes the warnings go away. Of course, I can't do that because the normal wiki user doesn't have permission to create/alter/drop tables :)

I've discovered the deprecated warnings appear when you define the following variables in LocalSettings.php, even if you have no loaded skin or extension:

$wgDBadminuser = 'zzzz;
$wgDBadminpassword = 'zzzz';

Removing them from LocalSettings.php makes the warnings go away. Of course, I can't do that because the normal wiki user doesn't have permission to create/alter/drop tables :)

Paste the warnings? Stack trace (maybe? :P)

Those two $wg aren't touched in execution except in maintenance, installer, tests/phpunit...