Last modified: 2006-10-22 19:53:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T6529, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 4529 - Passing template parameters to parser hook extensions
Passing template parameters to parser hook extensions
Status: RESOLVED DUPLICATE of bug 2257
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.6.x
All All
: Normal normal with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: parser, patch
: 4585 (view as bug list)
Depends on: 684
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-08 02:26 UTC by Ævar Arnfjörð Bjarmason
Modified: 2006-10-22 19:53 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
minimal patch to expose template args for use in extension callbacks, etc. (1.14 KB, patch)
2006-03-01 00:31 UTC, Dossy Shiobara
Details
Fix for 1.7-svn (1.44 KB, patch)
2006-05-12 02:13 UTC, Evan Miller
Details

Description Ævar Arnfjörð Bjarmason 2006-01-08 02:26:27 UTC
There should be some way to pass template parameters to parser hook extensions,
Tim Starling changed some stuff in rev 1.489 of Parser.php to allow for this but
reverted it in rev 1.498 because of some breakage with it.

There are two ways to solve this, one would be to add a flag to
Parser::setHook() that indicates that the extension being hooked returns
wikitext, it could then return stuff like "[[{{{foo}}}]]" and have the Parser
DWIM, the other way would be to bring something like the old hack back, the
former would work for most cases but it would also be nice to access template
parameters in hooks that don't return wikitext.

== Relevant diffs:
=== Adding support
cvs diff -u -r 1.488 -r 1.489 Parser.php
r1=text&r2=text&diff_format=u">http://cvs.sourceforge.net/viewcvs.py/wikipedia/phase3/includes/Parser.php?tr1=1.488&tr2=1.489&r1=text&r2=text&diff_format=u
=== Removing support
cvs diff -u -r 1.497 -r 1.498 Parser.php
r1=text&r2=text&diff_format=u">http://cvs.sourceforge.net/viewcvs.py/wikipedia/phase3/includes/Parser.php?tr1=1.497&tr2=1.498&r1=text&r2=text&diff_format=u
Comment 1 Ævar Arnfjörð Bjarmason 2006-01-12 21:52:25 UTC
*** Bug 4585 has been marked as a duplicate of this bug. ***
Comment 2 Dossy Shiobara 2006-03-01 00:23:17 UTC
See also: bug 2257
Comment 3 Dossy Shiobara 2006-03-01 00:25:28 UTC
I have a minimal change to MediaWiki 1.5.0 that lets me at least access the
template args from my extension (which is all I currently need).  It's a
three-line change to includes/Parser.php:

107c107
<       var $mOptions, $mTitle, $mOutputType,
---
>       var $mOptions, $mTitle, $mOutputType, $mTemplateArgs,
126a127
>               $this->mTemplateArgs = array();
2294a2296,2297
>                               # Store a copy of template args so extensions
can use them.
>                               $this->mTemplateArgs = $assocArgs;

In my extension, I can now do:

...
global $wgParser;
$text = $wgParser->replaceVariables($input, $wgParser->mTemplateArgs);
...

Any reason not to do this?
Comment 4 Dossy Shiobara 2006-03-01 00:31:36 UTC
Created attachment 1423 [details]
minimal patch to expose template args for use in extension callbacks, etc.

With this patch, I can now do this from an extension:

...
global $wgParser;
$text = $wgParser->replaceVariables($input, $wgParser->mTemplateArgs);
...
Comment 5 Evan Miller 2006-05-12 02:13:18 UTC
Created attachment 1711 [details]
Fix for 1.7-svn

Same changes as #1423, but for 1.7-svn.
Comment 6 Evan Miller 2006-10-22 19:53:04 UTC

*** This bug has been marked as a duplicate of 2257 ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links