From: jenkins-bot Date: Mon, 23 Sep 2019 15:28:03 +0000 (+0000) Subject: Merge "Add config for serving main Page from the domain root" X-Git-Tag: 1.34.0-rc.0~121 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=9e8439e79d67788916d488f645108f79016d9aca;hp=af80076034fb734d652eb043c523c1d8df974e51 Merge "Add config for serving main Page from the domain root" --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index fd1affce3d..1068700499 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -9094,6 +9094,13 @@ $wgSpecialSearchFormOptions = []; */ $wgNativeImageLazyLoading = false; +/** + * Option to whether serve the main page as the domain root + * @since 1.34 + * @var bool + */ +$wgMainPageIsDomainRoot = false; + /** * For really cool vim folding this needs to be at the end: * vim: foldmarker=@{,@} foldmethod=marker diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index f91477af2e..28c9e16002 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -346,6 +346,10 @@ class MediaWiki { return false; } + if ( $this->config->get( 'MainPageIsDomainRoot' ) && $request->getRequestURL() === '/' ) { + return false; + } + if ( $title->isSpecialPage() ) { list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()-> resolveAlias( $title->getDBkey() ); diff --git a/includes/Title.php b/includes/Title.php index 9843e81962..6c15a062b0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2137,7 +2137,7 @@ class Title implements LinkTarget, IDBAccessObject { * @return string String of the URL. */ public function getLocalURL( $query = '', $query2 = false ) { - global $wgArticlePath, $wgScript, $wgServer, $wgRequest; + global $wgArticlePath, $wgScript, $wgServer, $wgRequest, $wgMainPageIsDomainRoot; $query = self::fixUrlQueryArgs( $query, $query2 ); @@ -2214,6 +2214,11 @@ class Title implements LinkTarget, IDBAccessObject { $url = $wgServer . $url; } } + + if ( $wgMainPageIsDomainRoot && $this->isMainPage() && $query === '' ) { + return '/'; + } + // Avoid PHP 7.1 warning from passing $this by reference $titleRef = $this; Hooks::run( 'GetLocalURL', [ &$titleRef, &$url, $query ] );