Allow relative inclusions in Main namespace.
authorVitaliy Filippov <vitalif@yourcmc.ru>
Thu, 30 May 2013 12:23:33 +0000 (16:23 +0400)
committerMatmarex <matma.rex@gmail.com>
Fri, 5 Jul 2013 13:07:46 +0000 (13:07 +0000)
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

includes/parser/Parser.php
tests/parser/parserTests.txt

index 28cde7f..c2eeb0a 100644 (file)
@@ -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 );
index d0f41e5..09e1c7c 100644 (file)
@@ -12065,6 +12065,45 @@ subpage title=[[Subpage test/L1/L2/L3]]
 </p>
 !! 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
+<p>Sibling article
+</p>
+!! end
+
+!! test
+Transclusion of a child page
+!! options
+subpage title=[[Subpage test/L1/L2]]
+!! input
+{{/L3Sibling}}
+!! result
+<p>Sibling article
+</p>
+!! end
+
+!! test
+Non-transclusion because of too many up levels
+!! options
+subpage title=[[Subpage test/L1/L2/L3]]
+!! input
+{{../../../../More than parent}}
+!! result
+<p>{{../../../../More than parent}}
+</p>
+!! end
+
 !! test
 Definition list code coverage
 !! input