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 );