Stas Bekman wrote:
Kurt George Gjerde wrote:

Stan and all,

I'll just send in things as I discover them. Nothing urgent; just file it
and look at it when time permits. Hope that's ok.


Under ModPerl::Registry (in script handled by Registry), $r->args is not
properly updated when the QUERY_STRING changes. Have to reload a couple of
times. Looks like a cache thing(?).


Changing http://example.com/?name=Janet to .../?name=Brian, $r->args still
contains "name=Janet".


On the other hand, is the availability of $r in registry scripts just a
side-effect? (should $r be available or not).


Hmm, interesting. You must have created a closure. I'm sure if you show a sample code this will be easier to understand.

Based on your side-effect comment, I think what you do is:

test.pl:
--------
$r->content_type('text/plain');
$r->print($r->args);

whereas you should do:

test.pl:
--------
my $r = shift;
$r->content_type('text/plain');
$r->print($r->args);

why? because what registry does is wrapping the code into a function handler, passing $r as an argument. However it's also in the scope of the code that calls this function, so it looks like it work. However if you change your code to:

test.pl:
--------
use warnings;
$r->content_type('text/plain');
$r->print($r->args);

you will see a warning:

Variable "$r" will not stay shared at /home/stas/apache.org/temp/ModPerl-Registry/t/cgi-bin/args.pl line 5.

I think there is a similar potential problem in mp1, but I haven't checked.

In any case I'll make sure that $r is not in scope. when handler is called.

Also make sure you have warnings enabled globally, this will prevent a lot of problems early.

PerlSwitches -wT

in httpd.conf.

The following patch will make sure that your script will complain under 'use strict' and it'll fail in any case, if it doesn't get its own $r . The problem doesn't exist in Apache::Registry, but does exist in Apache::PerlRun, I'll patch it.


Index: lib/ModPerl/RegistryCooker.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v
retrieving revision 1.33
diff -u -r1.33 RegistryCooker.pm
--- lib/ModPerl/RegistryCooker.pm       2 Mar 2003 23:23:57 -0000       1.33
+++ lib/ModPerl/RegistryCooker.pm       8 Mar 2003 03:44:38 -0000
@@ -628,12 +628,12 @@
 # args: $self - registry blessed object
 #       $eval - a ref to a scalar with the code to compile
 # rtrn: success/failure
+# note: $r must not be in scope of compile(), scripts must do
+#       my $r = shift; to get it off the args stack
 #########################################################################

 sub compile {
     my($self, $eval) = @_;
-
-    my $r = $self->{REQ};

$self->debug("compiling $self->{FILENAME}") if DEBUG && D_COMPILE;



__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to