Page MenuHomePhabricator

Inject services into special pages
Open, MediumPublic

Description

Now that T222388: Create a mechanism for SpecialPages and API modules to have dependencies injected into them has been resolved, the services required by special pages can be injected into the special pages.

Some pitfalls

Some special pages extended by extensions. These need to be updated to pass the services to the parent constructor and update their declaration to include the required services.

  1. Special pages constructors call SpecialPage::__construct directly, bypassing the parent constructor and thus the injected dependency.

Event Timeline

Change 535657 had a related patch set uploaded (by Mainframe98; owner: Mainframe98):
[mediawiki/core@master] Inject services into special pages

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

For the listed patch, this code search shows which extensions will break due to the patch above.

Right now, this is blocked on a circular dependency issue caused by a combination of MediaWiki-extensions-GlobalPreferences and MobileFrontend. I'm not able to reproduce it locally however.

2019-10-02 10:12:56 84ad752757c0 wikidb: [e560b0d5a4e1a8ea2b773ccd] /index.php?title=Special%3AUserLogin   RuntimeException from line 448 of /workspace/src/includes/libs/services/ServiceContainer.php: Circular dependency when creating service! SpecialPageFactory -> PreferencesFactory -> PermissionManager -> SpecialPageFactory
#0 /workspace/src/includes/libs/services/ServiceContainer.php(427): Wikimedia\Services\ServiceContainer->createService(string)
#1 /workspace/src/includes/MediaWikiServices.php(995): Wikimedia\Services\ServiceContainer->getService(string)
#2 /workspace/src/includes/ServiceWiring.php(539): MediaWiki\MediaWikiServices->getSpecialPageFactory()
#3 /workspace/src/includes/libs/services/ServiceContainer.php(458): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#4 /workspace/src/includes/libs/services/ServiceContainer.php(427): Wikimedia\Services\ServiceContainer->createService(string)
#5 /workspace/src/includes/MediaWikiServices.php(834): Wikimedia\Services\ServiceContainer->getService(string)
#6 /workspace/src/extensions/GlobalPreferences/includes/Hooks.php(206): MediaWiki\MediaWikiServices->getPermissionManager()
#7 /workspace/src/includes/libs/services/ServiceContainer.php(458): GlobalPreferences\Hooks::GlobalPreferences\{closure}(MediaWiki\MediaWikiServices)
#8 /workspace/src/includes/libs/services/ServiceContainer.php(427): Wikimedia\Services\ServiceContainer->createService(string)
#9 /workspace/src/includes/MediaWikiServices.php(842): Wikimedia\Services\ServiceContainer->getService(string)
#10 /workspace/src/extensions/GlobalPreferences/includes/Hooks.php(289): MediaWiki\MediaWikiServices->getPreferencesFactory()
#11 /workspace/src/extensions/GlobalPreferences/includes/Hooks.php(43): GlobalPreferences\Hooks::getPreferencesFactory(User)
#12 /workspace/src/includes/Hooks.php(174): GlobalPreferences\Hooks::onUserLoadOptions(User, array)
#13 /workspace/src/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#14 /workspace/src/includes/user/User.php(5151): Hooks::run(string, array)
#15 /workspace/src/includes/user/User.php(2917): User->loadOptions()
#16 /workspace/src/extensions/MobileFrontend/includes/MobileContext.php(250): User->getOption(string)
#17 /workspace/src/extensions/MobileFrontend/includes/MobileContext.php(306): MobileContext->getMobileMode()
#18 /workspace/src/extensions/MobileFrontend/includes/features/StableUserMode.php(35): MobileContext->isBetaGroupMember()
#19 /workspace/src/extensions/MobileFrontend/includes/features/FeaturesManager.php(106): MobileFrontend\Features\StableUserMode->isEnabled()
#20 /workspace/src/extensions/MobileFrontend/includes/MobileFrontendHooks.php(510): MobileFrontend\Features\FeaturesManager->isFeatureAvailableForCurrentUser(string)
#21 /workspace/src/includes/Hooks.php(174): MobileFrontendHooks::onSpecialPageInitList(array)
#22 /workspace/src/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#23 /workspace/src/includes/ServiceWiring.php(748): Hooks::run(string, array)
#24 /workspace/src/includes/libs/services/ServiceContainer.php(458): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#25 /workspace/src/includes/libs/services/ServiceContainer.php(427): Wikimedia\Services\ServiceContainer->createService(string)
#26 /workspace/src/includes/MediaWikiServices.php(995): Wikimedia\Services\ServiceContainer->getService(string)
#27 /workspace/src/includes/Title.php(1222): MediaWiki\MediaWikiServices->getSpecialPageFactory()
#28 /workspace/src/includes/MediaWiki.php(196): Title->isSpecial(string)
#29 /workspace/src/includes/MediaWiki.php(974): MediaWiki->performRequest()
#30 /workspace/src/includes/MediaWiki.php(534): MediaWiki->main()
#31 /workspace/src/index.php(44): MediaWiki->run()
#32 {main}
kchapman triaged this task as Medium priority.Oct 7 2019, 7:57 PM

Change 576537 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Inject some services to special pages

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

Change 576537 merged by jenkins-bot:
[mediawiki/core@master] Inject some services to special pages

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

Change 618569 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Inject more services into SpecialPage classes

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

Change 535657 abandoned by Mainframe98:
[mediawiki/core@master] Inject services into special pages

Reason:
This change has collected too much digi-dust and is better broken up into smaller changes

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

Change 618569 abandoned by Umherirrender:
[mediawiki/core@master] Inject more services into SpecialPage classes

Reason:
This patch set is superseeded by many other patch sets already merged, pending parts are: Ifed2cbd2eee7166daf2e7d9bab017786247f88f6 for the NamespaceInfo in SpecialDeletedContributions and Ib0cbdb719d2a748622d843824b73ebb4c29fab89 for the AuthManager in SpecialLinkAccounts and SpecialCreateAccount. The other special pages are already done.

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