Page MenuHomePhabricator

Inject services into API modules and special pages
Open, LowPublic

Description

Since T222388 it has been possible to inject services into API modules and special pages.

Some SpecialPages in core now do this: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/58b7003abb72d4c042164ad7e2262c6a8e4f0f9a/includes/specialpage/SpecialPageFactory.php#69

API modules in core don't seem to do it yet: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/58b7003abb72d4c042164ad7e2262c6a8e4f0f9a/includes/api/ApiMain.php#61

SpecialPage and ApiBase access the service container directly.

There are discussions happening in code reviews on individual patches about whether (or when) we should be injecting services in core API modules and special pages. It would be good to have some guidance so we can resolve these conversations consistently.

Details

ProjectBranchLines +/-Subject
mediawiki/coremaster+25 -3
mediawiki/coremaster+182 -21
mediawiki/extensions/MultiUploadmaster+3 -2
mediawiki/coremaster+73 -17
mediawiki/coremaster+163 -28
mediawiki/coremaster+77 -27
mediawiki/coremaster+105 -23
mediawiki/coremaster+7 -0
mediawiki/coremaster+122 -55
mediawiki/coremaster+51 -21
mediawiki/coremaster+610 -158
mediawiki/extensions/QuizGamemaster+7 -4
mediawiki/extensions/GlobalPreferencesmaster+2 -2
mediawiki/extensions/SocialProfilemaster+6 -1
mediawiki/extensions/FanBoxesmaster+6 -1
mediawiki/extensions/PictureGamemaster+6 -1
mediawiki/extensions/PollNYmaster+6 -1
mediawiki/extensions/GlobalContribsmaster+4 -2
mediawiki/extensions/GlobalUserrightsmaster+2 -1
mediawiki/extensions/CentralAuthmaster+2 -1
mediawiki/coremaster+58 -42
mediawiki/coremaster+20 -50
mediawiki/coremaster+48 -14
mediawiki/coremaster+51 -21
mediawiki/extensions/ORESmaster+7 -3
mediawiki/coremaster+35 -44
mediawiki/coremaster+111 -29
mediawiki/coremaster+110 -35
mediawiki/coremaster+74 -15
mediawiki/coremaster+100 -31
mediawiki/coremaster+88 -19
mediawiki/coremaster+35 -41
mediawiki/coremaster+90 -33
mediawiki/coremaster+266 -35
mediawiki/coremaster+165 -33
mediawiki/coremaster+151 -78
mediawiki/coremaster+56 -72
mediawiki/coremaster+58 -14
mediawiki/coremaster+61 -22
mediawiki/coremaster+27 -6
mediawiki/coremaster+39 -11
mediawiki/coremaster+54 -17
mediawiki/coremaster+26 -6
mediawiki/coremaster+40 -12
mediawiki/coremaster+35 -9
mediawiki/coremaster+107 -25
mediawiki/coremaster+20 -3
mediawiki/coremaster+43 -20
mediawiki/coremaster+16 -5
mediawiki/coremaster+56 -12
mediawiki/coremaster+18 -4
mediawiki/coremaster+53 -14
mediawiki/coremaster+90 -39
mediawiki/coremaster+29 -10
mediawiki/coremaster+32 -18
mediawiki/coremaster+71 -19
mediawiki/coremaster+132 -31
mediawiki/coremaster+18 -6
mediawiki/coremaster+23 -5
mediawiki/coremaster+17 -5
mediawiki/coremaster+26 -12
mediawiki/coremaster+171 -44
mediawiki/coremaster+16 -7
mediawiki/coremaster+26 -7
mediawiki/coremaster+162 -34
mediawiki/coremaster+19 -4
mediawiki/coremaster+39 -14
mediawiki/coremaster+30 -5
mediawiki/coremaster+94 -29
mediawiki/coremaster+35 -12
mediawiki/coremaster+15 -6
mediawiki/coremaster+23 -3
mediawiki/coremaster+20 -13
mediawiki/coremaster+16 -5
mediawiki/coremaster+14 -3
mediawiki/coremaster+37 -6
mediawiki/coremaster+20 -5
mediawiki/coremaster+17 -8
mediawiki/coremaster+18 -4
mediawiki/coremaster+87 -32
mediawiki/coremaster+27 -6
mediawiki/coremaster+28 -7
mediawiki/coremaster+27 -7
mediawiki/coremaster+45 -18
mediawiki/coremaster+51 -27
mediawiki/coremaster+34 -8
mediawiki/coremaster+36 -12
mediawiki/coremaster+34 -9
mediawiki/coremaster+13 -8
mediawiki/coremaster+10 -6
mediawiki/coremaster+45 -12
mediawiki/coremaster+49 -8
mediawiki/coremaster+114 -43
mediawiki/coremaster+29 -26
mediawiki/coremaster+220 -41
mediawiki/coremaster+25 -9
mediawiki/coremaster+1 K -544
Show related patches Customize query in gerrit

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolveddmaza
ResolvedMainframe98
OpenNone
ResolvedDannyS712
OpenDannyS712
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenDannyS712
OpenNone
OpenDannyS712
OpenNone
OpenDannyS712
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change 635608 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject services into SpecialExport/SpecialImport

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

Change 635611 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject services into SpecialRandom and friends

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

Change 635616 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject services into SpecialRecentChanges/SpecialRecentChangesLinked

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

Change 635625 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject services into abstract ChangesListSpecialPage

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

Change 635627 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Allow inject of services into abstract QueryPage

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

Change 635574 merged by jenkins-bot:
[mediawiki/core@master] Inject UserCache into SpecialListFiles/SpecialNewFiles

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

Change 635344 merged by jenkins-bot:
[mediawiki/core@master] Inject dependencies into ApiSetNotificationTimestamp

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

Change 635876 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Allow to inject services into SpecialPage

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

I have created patch sets for all core special pages to inject the directly used services. See topic:specialPageDI for an overview - https://gerrit.wikimedia.org/r/q/topic:%22specialPageDI%22+(status:open%20OR%20status:merged)

I have not used the UserFactory and TitleFactory, both a new services and were not on my plan when beginning with this series of patch sets. That work should be done in follow ups. Sometimes it should be possible to use specialized services.
There are also deprecated functions used which have a service as replacement. Sometimes I have replaced it when the it was easy code, but function like User::getOption needs reorder of the code, which makes the review harder and I delayed it to follow ups.
There are still global state in special pages. When I saw static functions I have created task and linked from this task to track some issues.

I have also created patch sets for parent classes with services, these patch sets are under WIP and needing more ideas and discussion on how to provide the services and to allow usage in sub classes.

Change 635582 merged by jenkins-bot:
[mediawiki/core@master] Inject Parser into SpecialVersion

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

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

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

Change 636208 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Inject TalkPageNotificationManager into ApiClearHasMsg

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

Change 635608 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialExport/SpecialImport

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

Change 628477 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialProtectedpages

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

Change 633575 merged by jenkins-bot:
[mediawiki/core@master] Inject DBLoadBalancer into SpecialUncategorizedCategories

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

Change 635581 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialMyLanguage

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

Change 636208 merged by jenkins-bot:
[mediawiki/core@master] Inject TalkPageNotificationManager into ApiClearHasMsg

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

Change 628479 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialProtectedtitles

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

Change 634653 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialComparePages

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

Change 636457 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/ORES@master] Use SpecialPageFactory to create special pages in test

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

Change 636207 merged by jenkins-bot:
[mediawiki/core@master] Inject services into ApiChangeContentModel

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

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

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

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

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

Change 636695 merged by jenkins-bot:
[mediawiki/core@master] Inject services into ApiStashEdit

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

Change 636697 merged by jenkins-bot:
[mediawiki/core@master] Inject services into ApiResetPassword

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

Change 636747 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject LinkBatchFactory into QueryPage and use it

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

Change 637542 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject ContentLanguage into SpecialPage and use it

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

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

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

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

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

Change 635585 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialAllPages/SpecialPrefixindex

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

Change 637884 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject DBLoadBalancer into abstract QueryPage (part 2)

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

Change 637542 merged by jenkins-bot:
[mediawiki/core@master] Inject ContentLanguage into SpecialPage and use it

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

Change 635627 merged by jenkins-bot:
[mediawiki/core@master] Inject DBLoadBalancer into abstract QueryPage

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

Change 637884 merged by jenkins-bot:
[mediawiki/core@master] Inject DBLoadBalancer into abstract QueryPage (part 2)

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

Change 636747 merged by jenkins-bot:
[mediawiki/core@master] Inject LinkBatchFactory into QueryPage and use it

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

Change 638173 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Change object specs for remaining un-serviced special pages

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

Change 635064 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialMovepage

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

Change 642087 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Inject UserCache into ApiUnblock

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

Change 642087 merged by jenkins-bot:
[mediawiki/core@master] Inject UserCache into ApiUnblock

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

Change 635579 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialSearch

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

Change 635611 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialRandom and friends

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

Change 634823 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialLog

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

Change 633808 merged by jenkins-bot:
[mediawiki/core@master] Inject AuthManager into SpecialPage and use it

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

Change 628528 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialAllMessages

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

Change 635876 merged by jenkins-bot:
[mediawiki/core@master] Inject SpecialPageFactory into SpecialPage and use it

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

Change 636457 merged by jenkins-bot:
[mediawiki/extensions/ORES@master] Use SpecialPageFactory to create special pages in test

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

Change 634553 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialUserrights

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

Change 634775 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialPreferences

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

Change 642859 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Revert "Inject services into SpecialUserrights"

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

Change 642859 merged by jenkins-bot:
[mediawiki/core@master] Revert "Inject services into SpecialUserrights"

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

Change 643299 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/CentralAuth@master] Prepare special page constructor for service injection in core

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

Change 643302 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/GlobalUserrights@master] Prepare special page constructor for service injection in core

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

Change 643303 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/GlobalPreferences@master] Prepare special page constructor for service injection in core

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

Change 643304 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/GlobalContribs@master] Prepare special page constructor for service injection in core

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

Change 643305 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/PollNY@master] Prepare special page constructor for service injection in core

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

Change 643306 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/PictureGame@master] Prepare special page constructor for service injection in core

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

Change 643308 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/FanBoxes@master] Prepare special page constructor for service injection in core

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

Change 643299 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] Prepare special page constructor for service injection in core

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

Change 643309 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/SocialProfile@master] Prepare special page constructor for service injection in core

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

Change 643310 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/QuizGame@master] Prepare special page constructor for service injection in core

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

Change 643311 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/MultiUpload@master] Prepare special page constructor for service injection in core

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

Change 643155 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Reapply "Inject services into SpecialUserrights"

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

Change 643302 merged by jenkins-bot:
[mediawiki/extensions/GlobalUserrights@master] Prepare special page constructor for service injection in core

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

Change 643304 merged by jenkins-bot:
[mediawiki/extensions/GlobalContribs@master] Prepare special page constructor for service injection in core

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

Change 643305 merged by jenkins-bot:
[mediawiki/extensions/PollNY@master] Prepare special page constructor for service injection in core

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

Change 643306 merged by jenkins-bot:
[mediawiki/extensions/PictureGame@master] Prepare special page constructor for service injection in core

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

Change 643308 merged by jenkins-bot:
[mediawiki/extensions/FanBoxes@master] Prepare special page constructor for service injection in core

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

Change 643309 merged by jenkins-bot:
[mediawiki/extensions/SocialProfile@master] Prepare special page constructor for service injection in core

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

Change 643318 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Add release notes about service injection in special pages

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

Change 643303 merged by jenkins-bot:
[mediawiki/extensions/GlobalPreferences@master] Prepare special page constructor for service injection in core

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

Change 643155 merged by jenkins-bot:
[mediawiki/core@master] Reapply "Inject services into SpecialUserrights"

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

Change 628539 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialContributions/SpecialDeletedContributions

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

Change 643310 merged by jenkins-bot:
[mediawiki/extensions/QuizGame@master] Prepare special page constructor for service injection in core

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

Change 635372 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialWatchlist/SpecialEditWatchlist

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

Change 643318 merged by jenkins-bot:
[mediawiki/core@master] Add release notes about service injection in special pages

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

Change 635616 merged by jenkins-bot:
[mediawiki/core@master] Inject services into SpecialRecentChanges/SpecialRecentChangesLinked

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

Change 638173 merged by jenkins-bot:
[mediawiki/core@master] Change object specs for remaining un-serviced special pages

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

Change 637558 merged by jenkins-bot:
[mediawiki/core@master] Inject LanguageConverterFactory into special pages

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

Change 637670 merged by jenkins-bot:
[mediawiki/core@master] Inject SearchEngineFactory into special pages

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

Change 643311 merged by Umherirrender:
[mediawiki/extensions/MultiUpload@master] Prepare special page constructor for service injection in core

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

Change 635625 abandoned by Umherirrender:
[mediawiki/core@master] Inject services into abstract ChangesListSpecialPage

Reason:
May be needs another way to handle the injection and the way to usethe injected services to all user of this special page.
Keep that open for another developer

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

Change 618781 abandoned by Umherirrender:
[mediawiki/core@master] Inject the needed dependencies into ApiBlock

Reason:
Code changed in Ifdced735b694b85116cb0e43dadbfa8e4cdb8cab

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