From 5f1852f85871753f08b0fb4c007c184a2b5a7f5f Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 8 Sep 2008 22:53:44 +0000 Subject: [PATCH] (bug 15528) Don't fail fatally on invalid titles This is a corollary to r40496, which didn't restore the behavior of make*LinkObj() on being passed a non-Title, only link(). --- includes/Linker.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index aa21f90e5c..176bd28197 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -305,6 +305,11 @@ class Linker { } private function linkText( $target ) { + # We might be passed a non-Title by make*LinkObj(). Fail gracefully. + if( !$target instanceof Title ) { + return ''; + } + # If the target is just a fragment, with no title, we return the frag- # ment text. Otherwise, we return the title text itself. if( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) { @@ -426,7 +431,7 @@ class Linker { * the end of the link. * @param $prefix String: optional prefix. As trail, only before instead of after. */ - function makeLinkObj( Title $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { + function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { global $wgUser; wfProfileIn( __METHOD__ ); @@ -458,7 +463,7 @@ class Linker { * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead * @return the a-element */ - function makeKnownLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { + function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { wfProfileIn( __METHOD__ ); if ( $text == '' ) { @@ -490,7 +495,7 @@ class Linker { * be included in the link text. Other characters will be appended after * the end of the link. */ - function makeBrokenLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) { wfProfileIn( __METHOD__ ); list( $inside, $trail ) = Linker::splitTrail( $trail ); -- 2.20.1