Improve Community Main Menu element handling

The Commmunity Portal main menu element should be handled
same way as Skin::buildSideBar() does:

 - it should ignore "-" -> this is how editors disable the
 link
 - it should use inContentLanguage() to properly support
 different languages

Bug: T216152
Change-Id: I41b2373fd1b55d9d4beaba60eeb362e6188d24de
This commit is contained in:
Piotr Miazga 2019-04-27 00:09:23 +02:00 committed by Pmiazga
parent 440e725030
commit 0ef74abc2d

View file

@ -22,6 +22,7 @@ namespace MediaWiki\Minerva\Menu;
use IContextSource;
use MediaWiki\Special\SpecialPageFactory;
use Message;
use MinervaUI;
use MWException;
use SpecialMobileWatchlist;
@ -298,8 +299,13 @@ final class Definitions {
* @throws MWException
*/
public function insertCommunityPortal( Group $group ) {
$titleName = \MessageCache::singleton()->get( 'Portal-url' );
if ( !$titleName || \Http::isValidURI( $titleName ) ) {
$message = new Message( 'Portal-url' );
if ( !$message->exists() ) {
return;
}
$inContentLang = $message->inContentLanguage();
$titleName = $inContentLang->plain();
if ( $inContentLang->isDisabled() || \Http::isValidURI( $titleName ) ) {
return;
}
$title = Title::newFromText( $titleName );