Page MenuHomePhabricator

Broken template expansion with nested template parameters
Closed, ResolvedPublic

Description

Would be great to add support of the date and time related magic words:
https://www.mediawiki.org/wiki/Help:Magic_words#Date_and_time

This affects rendering of pages using them in many ways, for example in certain use cases, this breaks transclusions (see {{Wîkîpediya:....):
http://parsoid.wmflabs.org/_rt/kuwiki/Destp%C3%AAk?oldid=614600


Version: unspecified
Severity: normal

Details

Reference
bz62716

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:55 AM
bzimport added a project: Parsoid-DOM.
bzimport set Reference to bz62716.

We are using the PHP preprocessor's implementation of these magic words. I looked at your example, and it seems that we don't properly expand the following wikitext:

{{Wîkîpediya:Di dîrokê de îro/{{CURRENTDAY}}'ê {{#ifeq:{{CURRENTMONTHNAME}}|reşemî|reşemiyê|{{CURRENTMONTHNAME}}ê}}}}

In data-mw HTML the nested ifeq is listed as a separate part, which looks wrong. So this seems to be a general template expansion issue rather than specific to these magic words. Adjusting the title to reflect this.

I'm also seeing an error when parsing this article locally:
TypeError: Cannot read property 'dataAttribs' of undefined

at WikitextSerializer.escapeTplArgWT (/home/gabriel/src/parsoid/lib/wts.escapeWikitext.js:732:46)
at pushArg (/home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:536:28)
at /home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:553:7
at Array.forEach (native)
at /home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:550:16
at Array.map (native)
at WikitextSerializer.WSP._buildTemplateWT (/home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:487:11)
at Object.handle (/home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:655:30)
at WikitextSerializer.WSP._serializeNode (/home/gabriel/src/parsoid/lib/mediawiki.WikitextSerializer.js:1036:30)
at SerializerState.SSP.serializeChildren (/home/gabriel/src/parsoid/lib/wts.SerializerState.js:110:32)

SPAN { handle: [Function], sepnls: { before: [Function] } }
error in kuwiki:Destpêk
Error

at LogData.stack (/home/gabriel/src/parsoid/lib/LogData.js:82:53)
at LogData.fullMsg (/home/gabriel/src/parsoid/lib/LogData.js:37:32)
at Logger._defaultBackend (/home/gabriel/src/parsoid/lib/Logger.js:141:24)
at /home/gabriel/src/parsoid/lib/Logger.js:163:24
at /home/gabriel/src/parsoid/node_modules/async/lib/async.js:511:21
at /home/gabriel/src/parsoid/node_modules/async/lib/async.js:227:13
at /home/gabriel/src/parsoid/node_modules/async/lib/async.js:111:13
at Array.forEach (native)
at _each (/home/gabriel/src/parsoid/node_modules/async/lib/async.js:32:24)
at async.each (/home/gabriel/src/parsoid/node_modules/async/lib/async.js:110:9)

The problem here seems to be that the template target comes from expanding the {{#ifeq}} .. Wîkîpediya:Di dîrokê de îro/18'ê adarê .. I don't think our template expansion pipeline handles this scenario yet.

Test: echo "{{ech{{echo|o}}|foo}}" | node parse

The error in Comment 2 probably comes from the serializer when you try to roundtrip the incorrectly parsed page with bogus data-mw attributes.

I'm 99% certain that we used to handle this, so I'm suspecting that it got broken along the way. With the PHP preprocessor we pass the entire string to the API anyway. Maybe it got broken when we tried to distinguish between templates and parser functions?

Change 119540 had a related patch set uploaded by Subramanya Sastry:
WIP: Bug 62716: Fix buggy 'isConvertibleToString'

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

Change 119540 merged by jenkins-bot:
(Bug 62716) Fixed bug in detecting unresolvable tpl targets.

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