Background
We had a fatal which occurred if a menu item was created with just a href while working on adding the donate link to Vector 2022. This meant we needed to update Vector to defensively protect against fatals.
In Minerva adding the following hook will cause Minerva to fatal:
$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $out, &$s ) {
$s['user-menu']['x'] = [ 'icon' => 'x' ];
};Going forward it would be useful for skins to be able to make valid assumptions about menu items e.g. they have text/html and if they have an icon they also have a href by adding some basic validation to skin menu items. For now, we do minimal changes to avoid having to review too many existing links.
Acceptance criteria
- Check every menu item has a text or html key going forward (so it has a label)
- If a menu has an icon, check it also has a href.
Original
When sending a patch to Quibble (which runs MediaWiki tests), we get an unrelated tests errors:
TypeError: array_map(): Argument #2 ($array) must be of type array, null given
4) MediaWiki\Tests\Actions\ActionEntryPointTest::testViewRedirectPage
Failed asserting that '[7cd4412cbfda768dd2ce920d] [no req] TypeError: array_map(): Argument #2 ($array) must be of type array, null given
Backtrace:
from /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(192)\n
#0 /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(192): array_map()\n
#1 [internal function]: MediaWiki\Skins\Vector\Components\VectorComponentUserLinks::MediaWiki\Skins\Vector\Components\{closure}()\n
#2 /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(188): array_map()\n
#3 [internal function]: MediaWiki\Skins\Vector\Components\VectorComponentUserLinks::MediaWiki\Skins\Vector\Components\{closure}()\n
#4 /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(176): array_map()\n
#5 /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(153): MediaWiki\Skins\Vector\Components\VectorComponentUserLinks::updateMenuItemStyles()\n
#6 /workspace/src/skins/Vector/includes/Components/VectorComponentUserLinks.php(362): MediaWiki\Skins\Vector\Components\VectorComponentUserLinks->getMenus()\n
#7 /workspace/src/skins/Vector/includes/SkinVector22.php(523): MediaWiki\Skins\Vector\Components\VectorComponentUserLinks->getTemplateData()\n
#8 /workspace/src/includes/Skin/SkinMustache.php(51): MediaWiki\Skins\Vector\SkinVector22->getTemplateData()\n
#9 /workspace/src/includes/Skin/SkinTemplate.php(172): MediaWiki\Skin\SkinMustache->generateHTML()\n
#10 /workspace/src/includes/Skin/Skin.php(670): MediaWiki\Skin\SkinTemplate->outputPage()\n
#11 /workspace/src/includes/Output/OutputPage.php(3313): MediaWiki\Skin\Skin->outputPageFinal()\n
#12 /workspace/src/includes/Actions/ActionEntryPoint.php(162): MediaWiki\Output\OutputPage->output()\n
#13 /workspace/src/includes/MediaWikiEntryPoint.php(180): MediaWiki\Actions\ActionEntryPoint->execute()\n
#14 /workspace/src/tests/phpunit/includes/Actions/ActionEntryPointTest.php(497): MediaWiki\MediaWikiEntryPoint->run()\n
#15 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestCase.php(1617): MediaWiki\Tests\Actions\ActionEntryPointTest->testViewRedirectPage()\n
#16 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestCase.php(1223): PHPUnit\Framework\TestCase->runTest()\n
#17 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestResult.php(729): PHPUnit\Framework\TestCase->runBare()\n
#18 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestCase.php(973): PHPUnit\Framework\TestResult->run()\n
#19 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(685): PHPUnit\Framework\TestCase->run()\n
#20 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(685): PHPUnit\Framework\TestSuite->run()\n
#21 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(685): PHPUnit\Framework\TestSuite->run()\n
#22 /workspace/src/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(651): PHPUnit\Framework\TestSuite->run()\n
#23 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(146): PHPUnit\TextUI\TestRunner->run()\n
#24 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run()\n
#25 /workspace/src/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()\n
#26 /workspace/src/vendor/bin/phpunit(122): include(string)\n
#27 {main}\n