Last modified: 2011-06-08 20:34:10 UTC
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.
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?
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.