aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Dziewoński <matma.rex@gmail.com>2018-08-01 03:13:18 +0200
committerBartosz Dziewoński <matma.rex@gmail.com>2018-08-01 16:19:55 +0200
commit26bb9d9b23eb2075eefca2097ca393a9d4aa3264 (patch)
treed2f5412fece38dce428782c7fb0216c9df9a80cc
parent3c4f47cd8cc63dbc0ac31984108874deb2e6f078 (diff)
downloadmediawikicore-26bb9d9b23eb2075eefca2097ca393a9d4aa3264.tar.gz
mediawikicore-26bb9d9b23eb2075eefca2097ca393a9d4aa3264.zip
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
-rw-r--r--includes/logging/LogFormatter.php9
-rw-r--r--languages/i18n/en.json1
-rw-r--r--languages/i18n/qqq.json1
3 files changed, 9 insertions, 2 deletions
diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php
index d59c6aa1ca04..1380ef8e0e6f 100644
--- a/includes/logging/LogFormatter.php
+++ b/includes/logging/LogFormatter.php
@@ -642,13 +642,18 @@ class LogFormatter {
* @param Title|null $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 edc18bb0c2a8..50b85ef15aaa 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -376,6 +376,7 @@
"ns-specialprotected": "Special pages cannot be edited.",
"titleprotected": "This title has been protected from creation by [[User:$1|$1]].\nThe reason given is <em>$2</em>.",
"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 d918a0806fff..d9bd995f15c0 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -576,6 +576,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}}",