stas 2003/12/18 18:25:43
Modified: ModPerl-Registry/lib/ModPerl RegistryCooker.pm PerlRun.pm
. Changes
Log:
Restore a proper behavior of all Registry handlers, but PerlRun, not
to reset %INC to forget any .pl files required during the script's
execution.
Revision Changes Path
1.39 +25 -6 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.38
retrieving revision 1.39
diff -u -u -r1.38 -r1.39
--- RegistryCooker.pm 23 Nov 2003 21:26:01 -0000 1.38
+++ RegistryCooker.pm 19 Dec 2003 02:25:43 -0000 1.39
@@ -177,7 +177,10 @@
my $cv = \&{"$package\::handler"};
- my %orig_inc = %INC;
+ my %orig_inc;
+ if ($self->should_reset_inc_hash) {
+ %orig_inc = %INC;
+ }
{ # run the code and preserve warnings setup when it's done
no warnings;
@@ -185,11 +188,16 @@
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{$_};
+ if ($self->should_reset_inc_hash) {
+ # to avoid the bite of require'ing a file with no package delaration
+ # Apache::PerlRun in mod_perl 1.15_01 started to localize %INC
+ # later on it has been adjusted to preserve loaded .pm files,
+ # which presumably contained the package declaration
+ for (keys %INC) {
+ next if $orig_inc{$_};
+ next if /\.pm$/;
+ delete $INC{$_};
+ }
}
$self->flush_namespace;
@@ -457,6 +465,17 @@
sub should_compile_once {
not shift->is_cached;
}
+
+#########################################################################
+# func: should_reset_inc_hash
+# dflt: FALSE
+# desc: decide whether to localize %INC for required .pl files from the script
+# args: $self - registry blessed object
+# rtrn: TRUE if should reset
+# FALSE otherwise
+#########################################################################
+
+*should_reset_inc_hash = \&FALSE;
#########################################################################
# func: flush_namespace
1.8 +1 -0 modperl-2.0/ModPerl-Registry/lib/ModPerl/PerlRun.pm
Index: PerlRun.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/PerlRun.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -u -r1.7 -r1.8
--- PerlRun.pm 23 Nov 2003 21:26:01 -0000 1.7
+++ PerlRun.pm 19 Dec 2003 02:25:43 -0000 1.8
@@ -42,6 +42,7 @@
get_mark_line => 'get_mark_line',
compile => 'compile',
error_check => 'error_check',
+ should_reset_inc_hash => 'TRUE',
strip_end_data_segment => 'strip_end_data_segment',
convert_script_to_compiled_handler => 'convert_script_to_compiled_handler',
);
1.290 +4 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.289
retrieving revision 1.290
diff -u -u -r1.289 -r1.290
--- Changes 19 Dec 2003 01:17:31 -0000 1.289
+++ Changes 19 Dec 2003 02:25:43 -0000 1.290
@@ -12,6 +12,10 @@
=item 1.99_12-dev
+Restore a proper behavior of all Registry handlers, but PerlRun, not
+to reset %INC to forget any .pl files required during the script's
+execution. [Stas]
+
<Perl> are now evaluating code into one distinct namespace per
container, similar to ModPerl::Registry scripts. [Philippe M. Chiasson]