stas        2003/01/06 02:42:38

  Modified:    ModPerl-Registry/lib/ModPerl RegistryCooker.pm
               .        Changes
  Added:       ModPerl-Registry/t perlrun_require.t
               ModPerl-Registry/t/cgi-bin lib.pl perlrun_require.pl
  Log:
  Correct ModPerl::RegistryCooker to reset %INC, after compile for .pl
  files which don't declare the package + add tests to check that
  
  Revision  Changes    Path
  1.27      +9 -9      modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
  
  Index: RegistryCooker.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- RegistryCooker.pm 29 Dec 2002 10:08:08 -0000      1.26
  +++ RegistryCooker.pm 6 Jan 2003 10:42:38 -0000       1.27
  @@ -188,6 +188,8 @@
       my $rc = Apache::OK;
       my $cv = \&{"$package\::handler"};
   
  +    my %orig_inc = %INC;
  +
       { # run the code and preserve warnings setup when it's done
           no warnings;
           eval { $rc = $cv->($r, @_) };
  @@ -195,6 +197,13 @@
           ModPerl::Global::special_list_call(END => $package);
       }
   
  +    # %INC cleanup in case .pl files do not declare package ...;
  +    for (keys %INC) {
  +     next if $orig_inc{$_};
  +     next if /\.pm$/;
  +     delete $INC{$_};
  +    }
  +
       $self->flush_namespace;
   
       #XXX: $self->chdir_file("$Apache::Server::CWD/");
  @@ -366,20 +375,11 @@
                       ${ $self->[CODE] },
                       "\n}"; # last line comment without newline?
   
  -    my %orig_inc = %INC;
  -
       my $rc = $self->compile(\$eval);
       return $rc unless $rc == Apache::OK;
       $self->debug(qq{compiled package \"$self->[PACKAGE]\"}) if DEBUG & D_NOISE;
   
       #$self->chdir_file("$Apache::Server::CWD/");
  -
  -    # %INC cleanup in case .pl files do not declare package ...;
  -    for (keys %INC) {
  -     next if $orig_inc{$_};
  -     next if /\.pm$/;
  -     delete $INC{$_};
  -    }
   
   #    if(my $opt = $r->dir_config("PerlRunOnce")) {
   #    $r->child_terminate if lc($opt) eq "on";
  
  
  
  1.94      +3 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Changes   6 Jan 2003 05:12:38 -0000       1.93
  +++ Changes   6 Jan 2003 10:42:38 -0000       1.94
  @@ -10,6 +10,9 @@
   
   =item 1.99_08-dev
   
  +Correct ModPerl::RegistryCooker to reset %INC, after compile for .pl
  +files which don't declare the package + add tests to check that [Stas]
  +
   Log the real error message when Foo::Bar::sub_name fails to resolve,
   because of a problem in Foo::Bar, when Foo::Bar *was* found [Stas]
   
  
  
  
  1.1                  modperl-2.0/ModPerl-Registry/t/perlrun_require.t
  
  Index: perlrun_require.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  use Apache::TestRequest qw(GET);
  
  # XXX: use the same server setup to test
  
  plan tests => 2;
  
  my $url = "/same_interp/perlrun/perlrun_require.pl";
  my $same_interp = Apache::TestRequest::same_interp_tie($url);
  
  for (1..2) {
      # should not fail on the second request
      ok t_cmp(
          "1",
          req($same_interp, $url),
          "PerlRun requiering and external lib with subs",
         );
  }
  
  sub req {
      my($same_interp, $url) = @_;
      my $res = Apache::TestRequest::same_interp_do($same_interp,
                                                    \&GET, $url);
      return $res ? $res->content : undef;
  }
  
  
  
  1.1                  modperl-2.0/ModPerl-Registry/t/cgi-bin/lib.pl
  
  Index: lib.pl
  ===================================================================
  sub whatever { return 1;}
  1;
  
  
  
  1.1                  modperl-2.0/ModPerl-Registry/t/cgi-bin/perlrun_require.pl
  
  Index: perlrun_require.pl
  ===================================================================
  #!/usr/bin/perl
  
  use Apache::Test ();
  use File::Spec::Functions qw(catfile);
  
  my $vars = Apache::Test::config()->{vars};
  my $require = catfile $vars->{serverroot}, 'cgi-bin', 'lib.pl';
  
  require $require;
  
  print "Content-type: text/plain\n\n";
  
  print whatever();
  
  
  
  
  


Reply via email to