summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Extension.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-02-20 21:00:33 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-02-20 21:00:33 +0100
commit1237c19f93f456dbf75613538d5ac368b99d2af2 (patch)
tree9e72113adcd20e587b58e65615aec2a36e768443 /Bugzilla/Extension.pm
parent70a3ca1899e3310a67d20cf8cb7245d7fab5c5f1 (diff)
downloadbugzilla-1237c19f93f456dbf75613538d5ac368b99d2af2.tar.gz
bugzilla-1237c19f93f456dbf75613538d5ac368b99d2af2.tar.xz
Bug 531577: Fix the paths that single-file extensions (like extensions/Foo.pm)
look for their tempaltes and libraries in. r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Extension.pm')
-rw-r--r--Bugzilla/Extension.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/Bugzilla/Extension.pm b/Bugzilla/Extension.pm
index 793ae6043..2bd26c3ed 100644
--- a/Bugzilla/Extension.pm
+++ b/Bugzilla/Extension.pm
@@ -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');
}