Skip to content

Commit 4e78675

Browse files
authored
fixing issue where there would show fatal on special page (#36)
1 parent 5c7d8c3 commit 4e78675

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎ReleaseNotes.wiki‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
; Version 2.2.1 (May 4, 2026)
2+
* Fixed issue where if page did not exist it would cause a fatal error on special:SmartComments
3+
14
; Version 2.2.0 (Feb 3, 2026)
25
* Added 'X no. of comments on page' while viewing a page
36

‎extension.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Robin van der Wiel",
77
"Yvar Nanlohij"
88
],
9-
"version": "2.2.0",
9+
"version": "2.2.1",
1010
"url": "https://www.archixl.nl",
1111
"descriptionmsg": "sc-desc",
1212
"license-name": "GPL-2.0+",

‎src/SpecialPage/Special.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private function generateCommentTable(): string {
261261
$tableHtml .= Xml::openElement( 'tr', [
262262
'class' => "$rowClass",
263263
'data-author' => $comment->getAuthor()->getName(),
264-
'data-page' => $comment->getPage(),
264+
'data-page' => $comment->getPage() ?? wfMessage( 'sc-page-not-found' )->text(),
265265
'data-status' => $comment->getStatus()
266266
] );
267267
$tableHtml .= Xml::element( 'td', null, wfMessage('sc-status-' . $comment->getStatus() ) );
@@ -483,6 +483,9 @@ private function getValidCssName( $string ) {
483483
*/
484484
private function getPageUrl( $pageName ): string {
485485
$title = Title::newFromText( $pageName );
486+
if ( $pageName === null ) {
487+
return wfMessage( 'sc-page-not-found' )->text();
488+
}
486489
return ( $title instanceof Title ) ? $title->getLinkUrl() : '';
487490
}
488491

0 commit comments

Comments
 (0)