Hygiene: Do not insert Random menu entry if message do not exists

The `randompage-url` message might not be defined, or be set to
'-' which means - this text do not exist. Minerva should respect
that, instead of showing a link that points nowhere/to a '-' page

Bug: T188697
Change-Id: If97d29b0e25f3635e94bf3b80b051355ea49cf7d
This commit is contained in:
Piotr Miazga 2019-07-09 13:05:00 +02:00
parent d2e723daf9
commit f190f7492a

View file

@ -142,11 +142,13 @@ final class Definitions {
* @throws MWException
*/
public function insertRandomItem( Group $group ) {
$page = $this->context->msg( 'randompage-url' )->escaped();
// Random link
$pageMsg = new Message( 'randompage-url' );
if ( !$pageMsg->exists() ) {
return;
}
$group->insert( 'random' )
->addComponent( $this->context->msg( 'mobile-frontend-random-button' )->escaped(),
Title::newFromText( $page )->getLocalURL() . '#/random',
Title::newFromText( $pageMsg->escaped() )->getLocalURL() . '#/random',
MinervaUI::iconClass( 'random', 'before' ), [
'id' => 'randomButton',
'data-event-name' => 'random',