Subject: | Silently forgets value of unknown parameter despite die_on_bad_params set to false |
Date: | Wed, 22 Dec 2010 19:49:48 +0100 |
To: | bug-HTML-Template [...] rt.cpan.org |
From: | intrigeri <intrigeri [...] boum.org> |
Hi,
ikiwiki [0] is using HTML::Template. I am currently testing using
HTML::Template 2.9-2 (i.e. 2.9 upstream with second Debian packaging
patch level) and Perl v5.10.1 (Debian Squeeze).
[0] http://ikiwiki.info/
We are currently hunting a bug [1] that only appears once we started
using a template parameter that is not defined in the template. We set
this parameter like this:
$template->param(title_overridden => 1);
If I immediately try to access its value:
$template->param('title_overridden')
... I always get undef.
[1] http://ikiwiki.info/bugs/po:_plugin_should_not_override_the_title_on_the_homepage/
FYI we are passing the following options to the HTML::Template
constructor:
filter => sub {
my $text_ref = shift;
${$text_ref} = decode_utf8(${$text_ref});
},
loop_context_vars => 1,
die_on_bad_params => 0,
In order to fix this bug I have to pass (the undocumented)
"parent_global_vars => 1" to the HTML::Template constructor so that
HTML::Template::param initializes $param_map->{$param} before checking
its reference type. Setting "global_vars => 1" does not fix this bug.
I am pretty sure there is a better way to get the desired behavior,
either by passing a better suited parameter to the HTML::Template
constructor, or by fixing an underlying bug.
My debugging efforts lead me to think the
$options->{parent_global_vars} that can be seen by the param sub
$options->sometimes did not inherit the global_vars setting.
Bye,
--
intrigeri <intrigeri@boum.org>
| GnuPG key @ https://gaffer.ptitcanardnoir.org/intrigeri/intrigeri.asc
| OTR fingerprint @ https://gaffer.ptitcanardnoir.org/intrigeri/otr-fingerprint.asc
| We're dreaming of something else.
| Something more clandestine, something happier.