]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 531577: Fix the paths that single-file extensions (like extensions/Foo.pm)
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 20 Feb 2010 20:01:35 +0000 (12:01 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sat, 20 Feb 2010 20:01:35 +0000 (12:01 -0800)
look for their tempaltes and libraries in.
r=mkanat, a=mkanat (module owner)

Bugzilla/Extension.pm
Bugzilla/Install/Util.pm

index 793ae6043d590f8deaac79ff544ffaf8cb14d844..2bd26c3ed7b0b33076d3c0727491150f7c52c77a 100644 (file)
@@ -147,7 +147,13 @@ sub load_all {
 sub modify_inc {
     my ($class, $file) = @_;
 
-    __do_call($class, 'package_dir', $file);
+    # Note that this package_dir call is necessary to set things up
+    # for my_inc, even if we didn't take its return value.
+    my $package_dir = __do_call($class, 'package_dir', $file);
+    # Don't modify @INC for extensions that are just files in the extensions/
+    # directory. We don't want Bugzilla's base lib/CGI.pm being loaded as 
+    # Bugzilla::Extension::Foo::CGI or any other confusing thing like that.
+    return if $package_dir eq bz_locations->{'extensionsdir'};
     unshift(@INC, sub { __do_call($class, 'my_inc', @_) });
 }
 
@@ -194,6 +200,15 @@ use constant enabled => 1;
 sub lib_dir {
     my $invocant = shift;
     my $package_dir = __do_call($invocant, 'package_dir');
+    # For extensions that are just files in the extensions/ directory,
+    # use the base lib/ dir as our "lib_dir". Note that Bugzilla never
+    # uses lib_dir in this case, though, because modify_inc is prevented
+    # from modifying @INC when we're just a file in the extensions/ directory.
+    # So this particular code block exists just to make lib_dir return
+    # something right in case an extension needs it for some odd reason.
+    if ($package_dir eq bz_locations()->{'extensionsdir'}) {
+        return bz_locations->{'ext_libpath'};
+    }
     return File::Spec->catdir($package_dir, 'lib');
 }
 
index 1c6d5c4ee7009b94f7bd6fd9646e0c243f2ece3d..99aacb3e784eb2787202245a1a8e9ec820c9a546 100644 (file)
@@ -196,6 +196,9 @@ sub extension_template_directory {
     my $extension = shift;
     my $class = ref($extension) || $extension;
     my $base_dir = extension_package_directory($class);
+    if ($base_dir eq bz_locations->{'extensionsdir'}) {
+        return bz_locations->{'templatedir'};
+    }
     return "$base_dir/template";
 }