]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 731175: Bugzilla::Field shouldn't assume that someone else already loaded require...
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Feb 2012 16:15:57 +0000 (17:15 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 29 Feb 2012 16:15:57 +0000 (17:15 +0100)
r=glob a=LpSolit

Bugzilla/Field/Choice.pm
Bugzilla/Template.pm

index b4666a27c7945ab0d9eb13d08d3d7968cf8084a1..8c5873fdb171e6d9a7741bb1dc916d207ac5d68e 100644 (file)
@@ -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
index c0c9b5db9fbdd6a338cc95951190d965983d7db1..dcbe37b3fd57ba7c9551ad77aa574b35a541eed2 100644 (file)
@@ -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};
     }