From: Vitaliy Filippov
Date: Thu, 30 May 2013 12:23:33 +0000 (+0400)
Subject: Allow relative inclusions in Main namespace.
X-Git-Tag: 1.31.0-rc.0~19267
X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=f3fdd8742c0b6e267ccdfbcc1288f6e35343a7a9;p=lhc%2Fweb%2Fwiklou.git
Allow relative inclusions in Main namespace.
In previous versions of MediaWiki, relative inclusions ({{../name}})
were not handled properly in the Main namespace - it tried to include
Template:Parent/name instead of just Parent/name article. In other
namespaces they worked, though (all in case of enabled subpages). The
patch fixes this inconsistence and allows to use relative inclusions
in Main.
Change-Id: Ie04f23c180e501631c629a39b997796a1725fb67
---
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 28cde7f09f..c2eeb0aaa8 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -3296,8 +3296,9 @@ class Parser {
$ns = NS_TEMPLATE;
# Split the title into page and subpage
$subpage = '';
- $part1 = $this->maybeDoSubpageLink( $part1, $subpage );
- if ( $subpage !== '' ) {
+ $relative = $this->maybeDoSubpageLink( $part1, $subpage );
+ if ( $part1 !== $relative ) {
+ $part1 = $relative;
$ns = $this->mTitle->getNamespace();
}
$title = Title::newFromText( $part1, $ns );
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index d0f41e55e3..09e1c7c37a 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -12065,6 +12065,45 @@ subpage title=[[Subpage test/L1/L2/L3]]
!! end
+!! article
+Subpage test/L1/L2/L3Sibling
+!! text
+Sibling article
+!! endarticle
+
+!! test
+Transclusion of a sibling page (one level up)
+!! options
+subpage title=[[Subpage test/L1/L2/L3]]
+!! input
+{{../L3Sibling}}
+!! result
+Sibling article
+
+!! end
+
+!! test
+Transclusion of a child page
+!! options
+subpage title=[[Subpage test/L1/L2]]
+!! input
+{{/L3Sibling}}
+!! result
+Sibling article
+
+!! end
+
+!! test
+Non-transclusion because of too many up levels
+!! options
+subpage title=[[Subpage test/L1/L2/L3]]
+!! input
+{{../../../../More than parent}}
+!! result
+{{../../../../More than parent}}
+
+!! end
+
!! test
Definition list code coverage
!! input