From c49599293b25f5b4a07a90c87cb211559e255abb Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Sat, 27 Sep 2008 09:49:23 +0000 Subject: [PATCH] (bug 15739) Add $wgArticlePathForCurid to make links with only curid=# as the query string use the article path, rather than the script path. Intended for Wikinews and the DPL extension with showcurid=true, although may be useful in other scenarios, so put in core. --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 7 +++++++ includes/Title.php | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 828dc5b355..30609b30b7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -140,6 +140,8 @@ The following extensions are migrated into MediaWiki 1.14: restriction types on the protection form. * (bug 8440) Allow preventing blocked users from editing their talk pages * Improved upload file type detection for OpenDocument formats +* (bug 15739) Add $wgArticlePathForCurid to make links with only curid=# as the + query string use the article path, rather than the script path === Bug fixes in 1.14 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c1582bdbe8..b54d3b9b53 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3434,3 +3434,10 @@ $wgUseAutomaticEditSummaries = true; * Requires memcached. */ $wgPasswordAttemptThrottle = array( 'count' => 5, 'seconds' => 300 ); + +/** + * Allow using articlepath for links where the only querystring is a curid (e.g. use /wiki/Main_Page?curid=1) + * WARNING: This will not work for all hosts or configuration setup, so BE CAREFUL. + * Only use this setting if you have to, as it is not recommended. + */ +$wgArticlePathForCurid = false; diff --git a/includes/Title.php b/includes/Title.php index 9cfdba1437..b1fcce20d3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -809,7 +809,7 @@ class Title { */ public function getLocalURL( $query = '', $variant = false ) { global $wgArticlePath, $wgScript, $wgServer, $wgRequest; - global $wgVariantArticlePath, $wgContLang, $wgUser; + global $wgVariantArticlePath, $wgContLang, $wgUser, $wgArticlePathForCurid; if( is_array( $query ) ) { $query = wfArrayToCGI( $query ); @@ -833,7 +833,7 @@ class Title { } } else { $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); - if ( $query == '' ) { + if ( $query == '' || ($wgArticlePathForCurid && substr_count( $query, '&' ) == 0 && strpos( $query, 'curid=' ) === 0 ) ) { if( $variant != false && $wgContLang->hasVariants() ) { if( $wgVariantArticlePath == false ) { $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default @@ -845,6 +845,13 @@ class Title { } else { $url = str_replace( '$1', $dbkey, $wgArticlePath ); } + if( $query ){ + if( strpos( $url, '&' ) ){ + $url .= '&' . $query; + }else{ + $url .= '?' . $query; + } + } } else { global $wgActionPaths; $url = false; -- 2.20.1