From: Bartosz DziewoƄski Date: Wed, 1 Aug 2018 01:13:18 +0000 (+0200) Subject: LogFormatter: Fail softer when trying to link an invalid titles X-Git-Tag: 1.31.2~57 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7a6393fc2b961acb9a838b03c4564636b36f32c0 LogFormatter: Fail softer when trying to link an invalid titles Old log entries contain titles that used to be valid, but now are not. Bug: T185049 Change-Id: Ia66d901aedf1b385574b3910b29f020b3fd4bd97 (cherry picked from commit 26bb9d9b23eb2075eefca2097ca393a9d4aa3264) --- diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 681366af9b..432ef90143 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -23,6 +23,7 @@ THIS IS NOT A RELEASE YET * (T194052) Updated wikimedia/base-convert from 1.0.1 to 2.0.0. * (T199494) Fix notices in maintenance/removeUnusuedAccounts.php * (T209870) Fix SQL syntax error in MS-SQL initialisation file for new wikis +* (T185049) LogFormatter: Fail softer when trying to link an invalid titles == MediaWiki 1.31.1 == diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index bc0491f4cf..72f3c54bdb 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -636,13 +636,18 @@ class LogFormatter { * @param Title $title The page * @param array $parameters Query parameters * @param string|null $html Linktext of the link as raw html - * @throws MWException * @return string */ protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { if ( !$title instanceof Title ) { - throw new MWException( 'Expected title, got null' ); + $msg = $this->msg( 'invalidtitle' )->text(); + if ( !$this->plaintext ) { + return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg ); + } else { + return $msg; + } } + if ( !$this->plaintext ) { $html = $html !== null ? new HtmlArmor( $html ) : $html; $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 31adb7b947..9bb431a534 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -373,6 +373,7 @@ "ns-specialprotected": "Special pages cannot be edited.", "titleprotected": "This title has been protected from creation by [[User:$1|$1]].\nThe reason given is $2.", "filereadonlyerror": "Unable to modify the file \"$1\" because the file repository \"$2\" is in read-only mode.\n\nThe system administrator who locked it offered this explanation: \"$3\".", + "invalidtitle": "Invalid title", "invalidtitle-knownnamespace": "Invalid title with namespace \"$2\" and text \"$3\"", "invalidtitle-unknownnamespace": "Invalid title with unknown namespace number $1 and text \"$2\"", "exception-nologin": "Not logged in", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 6348926e8e..1b050ace36 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -570,6 +570,7 @@ "ns-specialprotected": "Error message displayed when trying to edit a page in the Special namespace", "titleprotected": "Used as error message. Parameters:\n* $1 - username; GENDER supported\n* $2 - reason for protection", "filereadonlyerror": "Parameters:\n* $1 - file name\n* $2 - file repository name\n* $3 - reason", + "invalidtitle": "Displayed when an invalid title was encountered (generally in a list) and there are no details about it to be shown.", "invalidtitle-knownnamespace": "Displayed when an invalid title was encountered (generally in a list), but the namespace number is known to exist.\n\nParameters:\n* $1 - (Unused) the namespace number\n* $2 - the namespace name in content language or {{msg-mw|blanknamespace}} for the main namespace\n* $3 - the part of the title after the namespace (e.g. SomeName for the page User:SomeName)", "invalidtitle-unknownnamespace": "Displayed when an invalid title was encountered (generally in a list) and the namespace number is unknown.\n\nParameters:\n* $1 - the namespace number\n* $2 - the part of the title after the namespace (e.g. SomeName for the page User:SomeName)", "exception-nologin": "Generic page title used on error page when a user is not logged in. Message used by the UserNotLoggedIn exception.\n{{Identical|Not logged in}}",