LogFormatter: Fail softer when trying to link an invalid titles
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 1 Aug 2018 01:13:18 +0000 (03:13 +0200)
committerJames D. Forrester <jforrester@wikimedia.org>
Fri, 30 Nov 2018 22:54:23 +0000 (14:54 -0800)
Old log entries contain titles that used to be valid, but now are not.

Bug: T185049
Change-Id: Ia66d901aedf1b385574b3910b29f020b3fd4bd97
(cherry picked from commit 26bb9d9b23eb2075eefca2097ca393a9d4aa3264)

RELEASE-NOTES-1.31
includes/logging/LogFormatter.php
languages/i18n/en.json
languages/i18n/qqq.json

index 681366a..432ef90 100644 (file)
@@ -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 ==
 
index bc0491f..72f3c54 100644 (file)
@@ -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 );
index 31adb7b..9bb431a 100644 (file)
        "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",
index 6348926..1b050ac 100644 (file)
        "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}}",