gozer       2004/09/13 17:04:51

  Modified:    lib/Apache compat.pm
               t/response/TestCompat apache_module.pm
  Log:
  Apache::Module get_config & top_module didn't need to be overriden
  methods, keep it simple with smart wrappers instead
  
  Revision  Changes    Path
  1.120     +17 -0     modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- compat.pm 13 Sep 2004 23:36:08 -0000      1.119
  +++ compat.pm 14 Sep 2004 00:04:51 -0000      1.120
  @@ -264,6 +264,23 @@
       $r;
   }
   
  +{
  +    require Apache::Module;
  +    my $orig_sub = *Apache::Module::top_module{CODE};
  +    *Apache::Module::top_module = sub {
  +        $orig_sub->();
  +    };
  +}
  +
  +{
  +    require Apache::Module;
  +    my $orig_sub = *Apache::Module::get_config{CODE};
  +    *Apache::Module::get_config = sub {
  +        shift if $_[0] eq 'Apache::Module';
  +        $orig_sub->(@_);
  +    };
  +}
  +
   package Apache::Server;
   # XXX: is that good enough? see modperl/src/modules/perl/mod_perl.c:367
   our $CWD = Apache::ServerUtil::server_root;
  
  
  
  1.2       +0 -6      modperl-2.0/t/response/TestCompat/apache_module.pm
  
  Index: apache_module.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache_module.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apache_module.pm  13 Sep 2004 23:36:08 -0000      1.1
  +++ apache_module.pm  14 Sep 2004 00:04:51 -0000      1.2
  @@ -19,9 +19,7 @@
   
   sub TestCompatApacheModuleParms {
       my($self, $parms, $args) = @_;
  -    Apache::compat::override_mp2_api('Apache::Module::get_config');
       my $config = Apache::Module->get_config($self, $parms->server);
  -    Apache::compat::restore_mp2_api('Apache::Module::get_config');
       $config->{data} = $args;
   }
   
  @@ -30,14 +28,10 @@
   
       plan $r, tests => 2;
        
  -    Apache::compat::override_mp2_api('Apache::Module::top_module');
       my $top_module = Apache::Module->top_module();
  -    Apache::compat::restore_mp2_api('Apache::Module::top_module');
       ok t_cmp (ref($top_module), 'Apache::Module');
   
  -    Apache::compat::override_mp2_api('Apache::Module::get_config');
       my $config = Apache::Module->get_config($self, $r->server);
  -    Apache::compat::restore_mp2_api('Apache::Module::get_config');
       ok t_cmp ($config->{data}, 'Test');
       
       OK;
  
  
  

Reply via email to