Page MenuHomePhabricator

[VariablesExtension] Transcluded pages fetch variables only for the first transclusion
Closed, DuplicatePublicBUG REPORT

Description

Author: lwchris

Description:
Occurred on MediaWiki 1.16.5

Used in this test: Page A, Template B and Template C

Page A:
a:{{#vardefineecho:v|2}}
b:{{B}}
b:{{B}}
a:{{#vardefineecho:v|{{#expr:{{#var:v}}+4}}}}
c:{{C}}
b:{{B}}

Template B:
{{#vardefineecho:v|{{#expr:{{#var:v}}+1}}}}

Template C:
{{#vardefineecho:v|{{#expr:{{#var:v}}+2}}}}

Expected output: a:2 b:3 b:4 a:8 c:10 b:11

Actual output: a:2 b:3 b:3 a:7 c:9 b:3

It's obvious the variable values are only retrieved once for the first transclusion of a template. Changes to the variables are visible for the transcluding page (see a:7), but not on the second, third, ... transclusion of any template.


Version: unspecified
Severity: normal

Details

Reference
bz29319

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:29 PM
bzimport set Reference to bz29319.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Jun 8 2011, 3:08 PM

lwchris wrote:

Complete version details:

MediaWiki 1.16.5
PHP 5.3.5
MySQL 5.5.8
ParserFunctions 1.3.0
Variables 1.3.1

No other parser hooks installed.

I created Template D
{{#vardefineecho:v|{{#expr:{{#var:v}}+3}}}}

and added d:{{D}} on Page A. Now I get a:2 b:3 b:3 a:7 c:9 b:3 d:12. Thus I think the problem is the transcluded pages are cached and therefore the parsing is only done once for all transclusions which would also explain why the changes are visible after the first transclusion but not applied twice or thrice.

Maybe a related variable is $wgTranscludeCacheExpiry?

lwchris wrote:

Okay meanwhile I'm sure that it's a caching issue. Following setup:

Template B:
{{#var:v}}

Page A:
{{#vardefine:v|1}}{{B}}
{{#vardefine:v|2}}{{B}}
Output: 1 1

An easy workaround is to add a pseudo unnamed parameter:

Page A:
{{#vardefine:v|1}}{{B|}}
{{#vardefine:v|2}}{{B|}}
Output: 1 2

Maybe there's some possibility to automatically disable caching if the page contains a variable parser hook.

Liuxinyu970226 added a subscriber: Danwe.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 8 2015, 10:46 AM
MGChecker changed the subtype of this task from "Task" to "Bug Report".Mar 1 2019, 11:36 PM