From 970a7ac8a8cd780c779a9c45f6993dd7dd6ec724 Mon Sep 17 00:00:00 2001 From: Krinkle Date: Sun, 1 May 2011 19:20:31 +0000 Subject: [PATCH] (bug 27916) Don't prefix wgServer in mw.util.wikiGetlink The check is not needed, if wgArticlePath is undefined there's probably a much bigger issue. The wgServer doesn't need to be prefixed to the link (if someone really needs it (ie. external tools using the script and somehow defining wgServer in mw.config) they can surely prefix wgServer themselfs. In most if not all cases this is used to create anchor tags, which are interprated by browsers relatively to the current window location and in some browsers it even auto-prefixes the current environment when setting the href/src attribute. I did a grep search for "wikiGetlink" in /trunk (including ./extensions), there was one usage that assumed the wgServer prefix. Turned out that was actually a workaround untill this bug was fixed. I remove that workaround ( in mw.util.isMainPage). --- languages/Language.php | 2 +- resources/mediawiki.util/mediawiki.util.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index 4462100225..05972b56d4 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2714,7 +2714,7 @@ class Language { /** * Checks that convertPlural was given an array and pads it to requested - * amound of forms by copying the last one. + * amount of forms by copying the last one. * * @param $count Integer: How many forms should there be at least * @param $forms Array of forms given to convertPlural diff --git a/resources/mediawiki.util/mediawiki.util.js b/resources/mediawiki.util/mediawiki.util.js index 5d2b5f912b..8da7de50f1 100644 --- a/resources/mediawiki.util/mediawiki.util.js +++ b/resources/mediawiki.util/mediawiki.util.js @@ -201,12 +201,7 @@ */ 'wikiGetlink' : function( str ) { - // Exist check is needed since replace() can only be called on a string - if ( mw.config.exists( ['wgServer', 'wgArticlePath'] ) ) { - return mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ).replace( '$1', this.wikiUrlencode( str ) ); - } else { - return false; - } + return mw.config.get( 'wgArticlePath' ).replace( '$1', this.wikiUrlencode( str ) ); }, /** @@ -296,7 +291,7 @@ // Also check for the title in related namespaces ? if ( typeof alsoRelated !== 'undefined' && alsoRelated === true ) { - var tabLink = mw.config.get( 'wgServer' ) + $( '#ca-talk' ).prev().find( 'a:first' ).attr( 'href' ); + var tabLink = $( '#ca-talk' ).prev().find( 'a:first' ).attr( 'href' ); isRelatedToMainpage = tabLink === mw.util.wikiGetlink( mw.config.get( 'wgMainPageTitle' ) ); return isRelatedToMainpage || isTheMainPage; -- 2.20.1