From: Frédéric Buclin Date: Wed, 29 Feb 2012 16:15:57 +0000 (+0100) Subject: Bug 731175: Bugzilla::Field shouldn't assume that someone else already loaded require... X-Git-Tag: bugzilla-4.3.1~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e3a5735240ad3bc777e245bf1ce1505e3579fda;p=thirdparty%2Fbugzilla.git Bug 731175: Bugzilla::Field shouldn't assume that someone else already loaded required modules r=glob a=LpSolit --- diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index b4666a27c7..8c5873fdb1 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -76,8 +76,10 @@ sub type { my $field_obj = blessed $field ? $field : Bugzilla::Field->check($field); my $field_name = $field_obj->name; - if ($class->CLASS_MAP->{$field_name}) { - return $class->CLASS_MAP->{$field_name}; + if (my $package = $class->CLASS_MAP->{$field_name}) { + # Callers expect the module to be already loaded. + eval "require $package"; + return $package; } # For generic classes, we use a lowercase class name, so as diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index c0c9b5db9f..dcbe37b3fd 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -10,7 +10,6 @@ package Bugzilla::Template; use strict; -use Bugzilla::Bug; use Bugzilla::Constants; use Bugzilla::WebService::Constants; use Bugzilla::Hook; @@ -19,10 +18,8 @@ use Bugzilla::Install::Util qw(install_string template_include_path include_languages); use Bugzilla::Keyword; use Bugzilla::Util; -use Bugzilla::User; use Bugzilla::Error; use Bugzilla::Search; -use Bugzilla::Status; use Bugzilla::Token; use Cwd qw(abs_path); @@ -315,7 +312,10 @@ sub get_bug_link { my $dbh = Bugzilla->dbh; if (defined $bug) { - $bug = blessed($bug) ? $bug : new Bugzilla::Bug($bug); + if (!blessed($bug)) { + require Bugzilla::Bug; + $bug = new Bugzilla::Bug($bug); + } return $link_text if $bug->{error}; }