[MediaWiki-commits] [Gerrit] Allow relative inclusions in Main namespace. - change (mediawiki/core)

2013-07-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Allow relative inclusions in Main namespace.
..


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
---
M includes/parser/Parser.php
M tests/parser/parserTests.txt
2 files changed, 42 insertions(+), 2 deletions(-)

Approvals:
  Matmarex: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 28cde7f..c2eeb0a 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -3296,8 +3296,9 @@
$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 d0f41e5..09e1c7c 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -12065,6 +12065,45 @@
 /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
+pSibling article
+/p
+!! end
+
+!! test
+Transclusion of a child page
+!! options
+subpage title=[[Subpage test/L1/L2]]
+!! input
+{{/L3Sibling}}
+!! result
+pSibling 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

-- 
To view, visit https://gerrit.wikimedia.org/r/66092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie04f23c180e501631c629a39b997796a1725fb67
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: VitaliyFilippov vita...@yourcmc.ru
Gerrit-Reviewer: Daniel Friesen dan...@nadir-seen-fire.com
Gerrit-Reviewer: Matmarex matma@gmail.com
Gerrit-Reviewer: Nemo bis federicol...@tiscali.it
Gerrit-Reviewer: Nikerabbit niklas.laxst...@gmail.com
Gerrit-Reviewer: VitaliyFilippov vita...@yourcmc.ru
Gerrit-Reviewer: jenkins-bot

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Allow relative inclusions in Main namespace. - change (mediawiki/core)

2013-05-30 Thread VitaliyFilippov (Code Review)
VitaliyFilippov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/66092


Change subject: Allow relative inclusions in Main namespace.
..

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. The patch 
fixes
this inconsistence and allows to use relative inclusions in Main.

Change-Id: Ie04f23c180e501631c629a39b997796a1725fb67
---
M includes/parser/Parser.php
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/92/66092/1

diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 840e174..4e61ef6 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -3296,8 +3296,9 @@
$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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/66092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie04f23c180e501631c629a39b997796a1725fb67
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: VitaliyFilippov vita...@yourcmc.ru

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits