Skip to content

Commit

Permalink
fix(components): catch MalformedTitleException in titleFromText
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 authored May 15, 2024
1 parent c09b82c commit 0006db6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion includes/Components/CitizenComponentUserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MediaWiki\Skins\Citizen\Components;

use MalformedTitleException;
use MediaWiki\MediaWikiServices;
use MediaWiki\Title\Title;
use MediaWiki\User\UserIdentity;
Expand Down Expand Up @@ -94,7 +95,11 @@ private function getUserGroups(): ?array {
foreach ( $groups as $group ) {
$id = sprintf( $msgKey, $group );
$text = $this->localizer->msg( $id )->text();
$title = $this->title->newFromText( $text, NS_PROJECT );
try {
$title = $this->title->newFromTextThrow( $text, NS_PROJECT );
catch ( MalformedTitleException $e ) {
// ignore
}

if ( !$text || !$title ) {
continue;
Expand Down

0 comments on commit 0006db6

Please sign in to comment.