jenkins-bot has submitted this change and it was merged.

Change subject: Bug 53359: Fix broken template parameter expansion
......................................................................


Bug 53359: Fix broken template parameter expansion

Template parameter expansions in a page that contained asynchronous default
values would not properly signal the asynchronous default parameter expansion
to the parent pipeline. They also did not properly strip EOFTk from parameter
expansions.

This resulted in async token buffers being emptied earlier than desired. Async
expansions would fire after the DOM was already fully built and sent to the
client, which in turn caused crashes in production.

Test case:

{{{icon|[[Image:Information.svg|25px|left]] }}} foo {{{{{echo|}}}echo|bar}}

Change-Id: Ib8f3445806864f4f3624fd4d7df24c7400051e1d
---
M js/lib/ext.core.TemplateHandler.js
1 file changed, 7 insertions(+), 6 deletions(-)

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



diff --git a/js/lib/ext.core.TemplateHandler.js 
b/js/lib/ext.core.TemplateHandler.js
index c6f309a..c4c1e1a 100644
--- a/js/lib/ext.core.TemplateHandler.js
+++ b/js/lib/ext.core.TemplateHandler.js
@@ -968,7 +968,7 @@
                // so that this chunk can be RT-ed en-masse.
                var tplHandler = this;
                newCB = function(res) {
-                       var toks = res.tokens;
+                       var toks = Util.stripEOFTkfromTokens(res.tokens);
                        var state = {
                                token: token,
                                wrapperType: "mw:Param",
@@ -981,16 +981,17 @@
        } else {
                newCB = cb;
        }
-       this.fetchArg(attribs[0].k, this.lookupArg.bind(this, args, attribs, 
newCB));
+       this.fetchArg(attribs[0].k, this.lookupArg.bind(this, args, attribs, 
newCB, cb), cb);
 };
 
-TemplateHandler.prototype.fetchArg = function(arg, argCB) {
+TemplateHandler.prototype.fetchArg = function(arg, argCB, asyncCB) {
        if (arg.constructor === String) {
                argCB({tokens: [arg]});
        } else {
                this.manager.frame.expand(arg, {
                        wrapTemplates: false,
                        type: "tokens/x-mediawiki/expanded",
+                       asyncCB: asyncCB,
                        cb: function(tokens) {
                                argCB({tokens: 
Util.stripEOFTkfromTokens(tokens)});
                        }
@@ -998,7 +999,7 @@
        }
 };
 
-TemplateHandler.prototype.lookupArg = function(args, attribs, cb, ret) {
+TemplateHandler.prototype.lookupArg = function(args, attribs, cb, asyncCB, 
ret) {
        var toks    = ret.tokens;
        var argName = toks.constructor === String ? toks : 
Util.tokensToString(toks).trim();
        var res     = args.dict[argName];
@@ -1011,14 +1012,14 @@
                } else {
                        res.get({
                                type: 'tokens/x-mediawiki/expanded',
-                               asyncCB: cb,
+                               asyncCB: asyncCB,
                                cb: (args.namedArgs[argName] ?
                                                function(res) { cb( {tokens: 
Util.tokenTrim(res)} ); } :
                                                function(res) { cb( {tokens: 
res} ); })
                        });
                }
        } else if (attribs.length > 1 ) {
-               this.fetchArg(attribs[1].v, cb);
+               this.fetchArg(attribs[1].v, cb, asyncCB);
        } else {
                //console.warn('no default for ' + argName + JSON.stringify( 
attribs ));
                cb({ tokens: [ '{{{' + argName + '}}}' ] });

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8f3445806864f4f3624fd4d7df24c7400051e1d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to