Skin: handle invalid titles gracefully
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Sat, 6 Dec 2014 09:50:10 +0000 (10:50 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Mon, 15 Dec 2014 18:46:17 +0000 (18:46 +0000)
Linker::link throws a notice if given null instead of title. Title
is constructed based on messages, so it can easily be null.

Change-Id: I5451135966cbb3bbd09d2568cec6b936f3b88aa3

includes/skins/Skin.php

index ce0c640..1a4ec98 100644 (file)
@@ -482,9 +482,10 @@ abstract class Skin extends ContextSource {
 
                        $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
                        $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
+                       $title = Title::newFromText( $linkPage );
+                       $link = $title ? Linker::link( $title, $msg ) : $msg;
                        $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
-                               Linker::link( Title::newFromText( $linkPage ), $msg )
-                               . $colon . '<ul>' . $t . '</ul>' . '</div>';
+                               $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
                }
 
                # Hidden categories
@@ -951,6 +952,10 @@ abstract class Skin extends ContextSource {
                        // but we make the link target be the one site-wide page.
                        $title = Title::newFromText( $this->msg( $page )->inContentLanguage()->text() );
 
+                       if ( !$title ) {
+                               return '';
+                       }
+
                        return Linker::linkKnown(
                                $title,
                                $this->msg( $desc )->escaped()