[Rt-devel] [patch] RT::Interface::Web _Overlay/_Vendor/_Local not being included

Tim Cutts tjrc at sanger.ac.uk
Wed Apr 27 08:17:25 EDT 2011


On 26 Apr 2011, at 01:05, Ivan Kohler wrote:

> Okay, how about this instead of the previous patch:
> 
> --- lib/RT/Base.pm      18 Apr 2011 23:04:59 -0000      1.1.1.11
> +++ lib/RT/Base.pm      25 Apr 2011 23:59:49 -0000
> @@ -166,11 +166,11 @@
> 
> sub _ImportOverlays {
>     my $class = shift;
> -    my ($package,undef,undef) = caller();
> -    $package =~ s|::|/|g;
> +    my ($package, $package_filename, undef) = caller();
> +    $package_filename =~ s/\.pm$//;
>     for (qw(Overlay Vendor Local)) {
> -        my $filename = $package."_".$_.".pm";
> -        eval { require $filename };
> +        my $filename = $package_filename."_".$_.".pm";
> +        eval " package $package; require '$filename'; ";
>         die $@ if ($@ && $@ !~ qr{^Can't locate $filename});
>     }
> }

I think this is close, but I don't think you need the string eval.  I've hit this same issue breaking RT::Extension::FastGroupRights, and the two changes I'm using are:

1)  Allow an override of the filename to be used:

--- RT/Base.pm.orig	2011-04-27 12:48:05.352246706 +0100
+++ RT/Base.pm	2011-04-27 13:14:42.214209587 +0100
@@ -166,7 +166,7 @@
 
 sub _ImportOverlays {
     my $class = shift;
-    my ($package,undef,undef) = caller();
+    my $package = shift || (caller())[0];
     $package =~ s|::|/|g;
     for (qw(Overlay Vendor Local)) {
         my $filename = $package."_".$_.".pm";

2) Make sure RT::Interface::Web overlays are loaded using that overridden filename:

--- RT/Interface/Web.pm.orig	2011-04-27 12:49:09.149185332 +0100
+++ RT/Interface/Web.pm	2011-04-27 12:52:52.954206821 +0100
@@ -2299,6 +2299,6 @@
     return ( _load_container_object( $obj_type, $obj_id ), $search_id );
 }
 
-RT::Base->_ImportOverlays();
+RT::Base->_ImportOverlays('RT::Interface::Web');
 
 1;

No string evals required, and everything seems to be loaded into the right namespace, from the right files.  At least, RT::Extension::FastGroupRights works for me now...

Tim



-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 


More information about the rt-devel mailing list