Right now there are ~60 lines of CSS, usually labeled /** Casual Game **/, bundled with various skins (due to historical reasons) but not with the RandomGameUnit extension, which is absurd as well as a Performance-Team issue, since we send out those extra 60 lines of CSS to everyone everywhere if they happen to be using one of the relevant skins.
Likewise, then there's a related, similar issue: since this CSS is skin and not extension-specific as it should be, it means that the parser hook output will look bad on skins which do not bundle this CSS!
Basically we'll want something like Change-Id: I9c0f1375b5f15b83fe3bc4859841735bfbe0a0df, only for RandomGameUnit. But wait, there's more! (Hence this task.)
RandomGameUnit::registerTag() is the function which registers the <randomgameunit> parser hook (=hooked into ParserFirstCallInit). The callback which renders the HTML is RandomGameUnit::getRandomGameUnit() (originally called wfGetRandomGameUnit) and its signature looks like this:
public static function getRandomGameUnit( $input = '', $argsv = array() ) {
There is no third $parser argument, which means we can't use the same techique as in RandomFeaturedUser to inject the ResourceLoader module into the parser output, and $input as well as $argsv -- despite that both are unused in the function -- have default values. Why, you might ask? Because RandomGameUnit::getRandomGameUnit() has external callers, as witnessed by a quick grep:
./extensions/BlogPage/BlogPageClass.php: return RandomGameUnit::getRandomGameUnit(); ./extensions/LinkFilter/LinkPage.php: return RandomGameUnit::getRandomGameUnit(); ./extensions/LinkFilter/SpecialLinksHome.php: return RandomGameUnit::getRandomGameUnit(); ./skins/Nimbus/Nimbus.skin.php: echo RandomGameUnit::getRandomGameUnit();
In BlogPage::getRandomCasualGame(), we can simply use $this->getContext->getOutput()->addModuleStyles( 'name of our brand new yet-to-be-created RL module' ); to inject the CSS; the same fix should work for LinkPage::getRandomCasualGame(), too; LinksHome::getRandomCasualGame() seems completely unused and might need to be removed; but we're then left with the Nimbus skin, which, as the grep results above show, uses echo to output the HTML.
How do we inject a ResourceLoader module into the output in a BaseTemplate's execute()?