mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
TopicSubscriptionsPager: Handle invalid titles
This approach is borrowed from PageQueryPage in MediaWiki core, and used in a few other places as well. Bug: T345648 Change-Id: I7fbc3c3c1133da78eb9f15de9b2a51a90bcd1980
This commit is contained in:
parent
3a9bbd66a8
commit
5d92dccafc
|
@ -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 {
|
|||
'</em>';
|
||||
} 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' ],
|
||||
|
|
Loading…
Reference in a new issue