Anomie has uploaded a new change for review.

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


Change subject: Use a child frame in frame:expandTemplate
......................................................................

Use a child frame in frame:expandTemplate

If we don't do this, then the section edit links point to the wrong page
if we expand a template that contains section headings.

Bug: 55525
Change-Id: I00bda935be3e8b9c0f86fd0f131814207fbb34a7
---
M engines/LuaCommon/LuaCommon.php
M tests/engines/LuaCommon/luaParserTests.txt
2 files changed, 25 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/11/89011/1

diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php
index 3cd7ea6..65f2dc6 100644
--- a/engines/LuaCommon/LuaCommon.php
+++ b/engines/LuaCommon/LuaCommon.php
@@ -451,7 +451,8 @@
                        throw new Scribunto_LuaError( 'expandTemplate: template 
loop detected' );
                }
 
-               $newFrame = $this->parser->getPreprocessor()->newCustomFrame( 
$args );
+               $fargs = 
$this->getParser()->getPreprocessor()->newPartNodeArray( $args );
+               $newFrame = $frame->newChild( $fargs, $finalTitle );
                $text = $this->doCachedExpansion( $newFrame, $dom, 
                        array(
                                'template' => $finalTitle->getPrefixedDBkey(),
diff --git a/tests/engines/LuaCommon/luaParserTests.txt 
b/tests/engines/LuaCommon/luaParserTests.txt
index ba79bab..ce3d271 100644
--- a/tests/engines/LuaCommon/luaParserTests.txt
+++ b/tests/engines/LuaCommon/luaParserTests.txt
@@ -113,6 +113,12 @@
        }
 end
 
+function p.testExpandTemplateWithHeaders( frame )
+       return frame:expandTemplate{
+               title = 'Scribunto_template_with_headers'
+       }
+end
+
 function p.testNewTemplateParserValue( frame )
        return 
                frame:newTemplateParserValue{
@@ -158,6 +164,12 @@
 Template:Scribunto_all_args
 !! text
 {{#invoke:test|getParentArgs}}
+!! endarticle
+
+!! article
+Template:Scribunto_template_with_headers
+!! text
+== bar ==
 !! endarticle
 
 !! test
@@ -275,6 +287,17 @@
 !! end
 
 !! test
+Scribunto: expandTemplate with headers
+!! input
+==foo==
+{{#invoke:test|testExpandTemplateWithHeaders}}
+!! result
+<h2><span class="mw-headline" id="foo">foo</span><span 
class="mw-editsection"><span class="mw-editsection-bracket">[</span><a 
href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit 
section: foo">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="bar">bar</span><span 
class="mw-editsection"><span class="mw-editsection-bracket">[</span><a 
href="/index.php?title=Template:Scribunto_template_with_headers&amp;action=edit&amp;section=T-1"
 title="Template:Scribunto template with headers">edit</a><span 
class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
+!! test
 Scribunto: newTemplateParserValue
 !! input
 {{#invoke:test|testNewTemplateParserValue}}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I00bda935be3e8b9c0f86fd0f131814207fbb34a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to