Avoid unstubbing $wgLang in Title::getLocalURL
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 16 May 2016 16:46:58 +0000 (12:46 -0400)
committerAnomie <bjorsch@wikimedia.org>
Mon, 16 May 2016 16:57:41 +0000 (16:57 +0000)
If $query doesn't match the regex, there's no point in unstubbing $wgLang if
that's what happens to be the page language. This also avoids it blowing up if
$wgLang isn't usable due to MW_NO_SESSION.

Bug: T135389
Change-Id: I9a6779c4cc887205215a815db3a765c35f060c42

includes/Title.php

index 876afe6..25fbce3 100644 (file)
@@ -1713,9 +1713,9 @@ class Title implements LinkTarget {
 
                                if ( $url === false
                                        && $wgVariantArticlePath
+                                       && preg_match( '/^variant=([^&]*)$/', $query, $matches )
                                        && $wgContLang->getCode() === $this->getPageLanguage()->getCode()
                                        && $this->getPageLanguage()->hasVariants()
-                                       && preg_match( '/^variant=([^&]*)$/', $query, $matches )
                                ) {
                                        $variant = urldecode( $matches[1] );
                                        if ( $this->getPageLanguage()->hasVariant( $variant ) ) {