Page MenuHomePhabricator

Cosmos fails to render in 1.36 with Uncaught ArgumentCountError: Too few arguments to function WantedPagesPage::__construct()
Closed, ResolvedPublic

Description

I am getting the following error with the latest version of Cosmos and MediaWiki:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function WantedPagesPage::__construct(), 0 passed in /Users/jrobson/git/core/skins/Cosmos/includes/CosmosTemplate.php on line 157 and exactly 2 expected in /Users/jrobson/git/core/includes/specials/SpecialWantedpages.php:38 Stack trace: #0 /Users/jrobson/git/core/skins/Cosmos/includes/CosmosTemplate.php(157): WantedPagesPage->__construct() #1 /Users/jrobson/git/core/skins/Cosmos/includes/CosmosTemplate.php(130): MediaWiki\Skin\Cosmos\CosmosTemplate::getMostWantedPages() #2 /Users/jrobson/git/core/skins/Cosmos/includes/CosmosTemplate.php(39): MediaWiki\Skin\Cosmos\CosmosTemplate->buildCreateArticleDialog() #3 /Users/jrobson/git/core/includes/skins/SkinTemplate.php(123): MediaWiki\Skin\Cosmos\CosmosTemplate->execute() #4 /Users/jrobson/git/core/includes/skins/SkinTemplate.php(138): SkinTemplate->generateHTML() #5 /Users/jrobson/git/core/includes/OutputPage.php(2626): SkinTemplate->outputPage() #6 /Users/jrobson/git/core/includes/exception/MWExceptionRenderer.php in /Users/jrobson/git/core/includes/specials/SpecialWantedpages.php on line 38

Event Timeline

That is only on 1.36, already know the cause and solution, but I am unsure how to maintain compatibility with 1.35, and add that to fix on 1.36.

$WantedPagesPageResponse = ( new WantedPagesPage( MediaWikiServices::getInstance()->getDBLoadBalancer(), MediaWikiServices::getInstance()->getLinkBatchFactory() ) )->doQuery();
Jdlrobson renamed this task from Cosmos fails to render in 1.35 with Uncaught ArgumentCountError: Too few arguments to function WantedPagesPage::__construct() to Cosmos fails to render in 1.36 with Uncaught ArgumentCountError: Too few arguments to function WantedPagesPage::__construct() .Dec 2 2020, 8:59 PM

It's possible WantedPagesPage is only for @internal usage in core. This should ideally be clarified cc @Umherirrender
Easiest option might be to wrap it in a try / catch block.

I'd suggest asking on T259960 for how best to use this.

Change 645136 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/skins/Cosmos@master] Use SpecialPageFactory to create special pages

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

The solution is to use SpecialPageFactory to instance the special page

All special page constructor are not part of the stable interface, using the factory resolves that problem

The solution is to use SpecialPageFactory to instance the special page

All special page constructor are not part of the stable interface, using the factory resolves that problem

Thank you!

Universal_Omega assigned this task to Umherirrender.
Universal_Omega raised the priority of this task from Medium to High.
Universal_Omega moved this task from Incoming / Backlog to Done on the Cosmos board.

Change 645136 merged by jenkins-bot:
[mediawiki/skins/Cosmos@master] Use SpecialPageFactory to create special pages

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