Page MenuHomePhabricator

[EPIC] Cleanup WikidataPageBanner architecture
Open, MediumPublic

Description

From https://gerrit.wikimedia.org/r/#/c/239010/

I found the (lack of) architecture hard to follow. Concpetually, what the extension does seems really simple - there is a list of banner sources (parser function, PageImages, Wikidata, global configuration), the first that can provide a banner name (according to some configurable order) will determine what is used. So I would expect a bunch of banner source classes, a configuration variable that contains a list of ObjectFactory arguments and a banner lookup class that goes through the sources the find which one can return a banner. Instead there is a hard-coded mess of static method calls, which is completely obscuring the logic.

overuse of static methods. Something like $wpbFunctionsClass::doStuff() should be a huge red flag.

Let's start cleaning this up step by step:

  • Convert includes/WikidataPageBannerFunctions.php into a set of classes
  • class Banner with methods addIcon, getHtml and addTOC
  • class WikidataBanner extends Banner
  • class BannerFactory( $title )
  • Cleanup addBanner in WikidataPageBanner should $banner = BannerFactory::newFrom( ... ); insertBannerIntoOutputPage( $banner );

Event Timeline

Jdlrobson raised the priority of this task from to Medium.
Jdlrobson updated the task description. (Show Details)
Jdlrobson subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdlrobson set Security to None.
Jdlrobson added a subscriber: Tgr.

While we are at it, document the config variables too.

Jdlrobson renamed this task from Cleanup WikidataPageBanner architecture to [EPIC] Cleanup WikidataPageBanner architecture.Apr 13 2017, 5:43 PM
Jdlrobson moved this task from Triaged but Future to Epics/Goals on the Web-Team-Backlog board.
Jdlrobson added a project: Epic.

Change 471288 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/WikidataPageBanner@master] DRY up onBeforePageDisplay

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

Change 471288 abandoned by Jdlrobson:
DRY up onBeforePageDisplay

Reason:
I have no code review support on this extension sadly.

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

Change 919397 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/extensions/WikidataPageBanner@master] WPB: use hookhandler and hook interfaces

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

Change 919461 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/extensions/WikidataPageBanner@master] Rename classes

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

Change 919397 merged by jenkins-bot:

[mediawiki/extensions/WikidataPageBanner@master] WPB: use hookhandler and hook interfaces

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

Change 919461 merged by jenkins-bot:

[mediawiki/extensions/WikidataPageBanner@master] Rename classes

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