diff --git a/includes/TopicSubscriptionsPager.php b/includes/TopicSubscriptionsPager.php index 66d6d2ed4..3ca767b70 100644 --- a/includes/TopicSubscriptionsPager.php +++ b/includes/TopicSubscriptionsPager.php @@ -5,6 +5,8 @@ namespace MediaWiki\Extension\DiscussionTools; use IContextSource; use InvalidArgumentException; use MediaWiki\Cache\LinkBatchFactory; +use MediaWiki\Html\Html; +use MediaWiki\Linker\Linker; use MediaWiki\Linker\LinkRenderer; use MediaWiki\Title\Title; use OOUI; @@ -79,11 +81,22 @@ class TopicSubscriptionsPager extends TablePager { ''; } else { $titleSection = Title::makeTitleSafe( $row->sub_namespace, $row->sub_title, $row->sub_section ); + if ( !$titleSection ) { + // Handle invalid titles (T345648) + return htmlspecialchars( $row->sub_section ); + } return $linkRenderer->makeLink( $titleSection, $row->sub_section ); } case '_page': $title = Title::makeTitleSafe( $row->sub_namespace, $row->sub_title ); + if ( !$title ) { + // Handle invalid titles (T345648) + return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], + Linker::getInvalidTitleDescription( + $this->getContext(), $row->sub_namespace, $row->sub_title ) + ); + } return $linkRenderer->makeLink( $title, $title->getPrefixedText() ); case 'sub_created': @@ -96,6 +109,12 @@ class TopicSubscriptionsPager extends TablePager { case '_unsubscribe': $title = Title::makeTitleSafe( $row->sub_namespace, $row->sub_title ); + if ( !$title ) { + // Handle invalid titles (T345648) + // The title isn't checked when unsubscribing, as long as it's a valid title, + // so specify something to make it possible to unsubscribe from the buggy entries. + $title = Title::newMainPage(); + } return (string)new OOUI\ButtonWidget( [ 'label' => $this->msg( 'discussiontools-topicsubscription-pager-unsubscribe-button' )->text(), 'classes' => [ 'ext-discussiontools-special-unsubscribe-button' ],