X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ftitle%2FMediaWikiTitleCodec.php;h=a937e757f1748ece52bbabe720fbc6c2854fc629;hb=e758226c91935a1df2b6fd3ed1f18922d8bfb45b;hp=5c504f3513d65a79de2bad5073efb3e9e19e4130;hpb=4424283e2a898948fa67e95ec56e8ce4e67e010f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index 5c504f3513..a937e757f1 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -105,10 +105,16 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { */ public function formatTitle( $namespace, $text, $fragment = '', $interwiki = '' ) { if ( $namespace !== false ) { - $namespace = $this->getNamespaceName( $namespace, $text ); + // Try to get a namespace name, but fallback + // to empty string if it doesn't exist + try { + $nsName = $this->getNamespaceName( $namespace, $text ); + } catch ( InvalidArgumentException $e ) { + $nsName = ''; + } - if ( $namespace !== '' ) { - $text = $namespace . ':' . $text; + if ( $namespace !== 0 ) { + $text = $nsName . ':' . $text; } } @@ -192,12 +198,18 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { if ( $target->isExternal() ) { $key .= $target->getInterwiki() . ':'; } - $nsName = $this->getNamespaceName( - $target->getNamespace(), - $target->getText() - ); + // Try to get a namespace name, but fallback + // to empty string if it doesn't exist + try { + $nsName = $this->getNamespaceName( + $target->getNamespace(), + $target->getText() + ); + } catch ( InvalidArgumentException $e ) { + $nsName = ''; + } - if ( $nsName !== '' ) { + if ( $target->getNamespace() !== 0 ) { $key .= $nsName . ':'; }