From 2e7ff851909cc108b2f885df08f4e92ec539a4ba Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" <> Date: Tue, 8 Feb 2005 00:43:09 +0000 Subject: Followup fix for bug 280770: improves reflection of constants into the templates' 'constants' namespace; r=wurblzap, a=myk --- Bugzilla/Template.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Bugzilla/Template.pm') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index a764848be..d4fcbe27c 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -23,6 +23,7 @@ # Bradley Baetz # Christopher Aillon # Tobias Burnus +# Myk Melez package Bugzilla::Template; @@ -38,12 +39,16 @@ use Date::Format (); use base qw(Template); # Convert the constants in the Bugzilla::Constants module into a hash we can -# pass to the template object. To do so, we have to traverse the symbol table -# for the module, pulling out the functions (which is how Perl constants are -# implemented) and ignoring the rest (i.e. things like the @EXPORT array). +# pass to the template object for reflection into its "constants" namespace +# (which is like its "variables" namespace, but for constants). To do so, we +# traverse the arrays of exported and exportable symbols, pulling out functions +# (which is how Perl implements constants) and ignoring the rest (which, if +# Constants.pm exports only constants, as it should, will be nothing else). use Bugzilla::Constants (); my %constants; -foreach my $constant (keys %Bugzilla::Constants::) { +foreach my $constant (@Bugzilla::Constants::EXPORT, + @Bugzilla::Constants::EXPORT_OK) +{ if (defined &{$Bugzilla::Constants::{$constant}}) { # Constants can be lists, and we can't know whether we're getting # a scalar or a list in advance, since they come to us as the return -- cgit v1.2.3-24-g4f1b