Re: $r-prev is always defined

2002-09-09 Thread Geoffrey Young



Jindo wrote:
 Hello,
 
 According to docs, $r-prev returns undef unless there is an internal
 redirect.  But to 
 my surprises, $r-prev is always defined, severely breaking down the
 code/flow logic 
 of my scripts.
 
 Here is what I have in /Index.cgi (My browser defaults to that page) for
 debugging
 $r-log_error($r-prev()-uri());
 $r-log_error($r-uri());

I'd suspect that it's probably mod_dir (via DirectoryIndex) that's 
causing this (since it calls ap_internal_redirect, which sets $r-prev 
and $r-prev-uri).

I also suspect that if you called /Index.cgi directly, you'd get a 500 
(and $r-prev would be undef so $r-prev-uri would bomb).

HTH

--Geoff




RE: $r-prev is always defined

2002-09-09 Thread Jindo

Hello,

Unfortunately, I did suspect the same before and called Index.cgi
directly.  By calling it directly, $r-log_error($r-prev()-uri())
still perfectly printed one line in error_log.

It's rather a very strange behaviour that I hope someone could figure it
out.  $r-prev() returns a blessed reference while $r-main() returns
undef.  This violates the logic because if $r-prev() does not return
undef, then $r-main() should returns something too as $r is one of the
subsequent internal redirects when $r-prev() is defined.

The workaround I came up is to test $r-main().  If I have the problem
figured out I'll let the list know.

Yours,

Jindo

-Original Message-
From: Geoffrey Young [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 09, 2002 9:35 PM
To: Jindo
Cc: [EMAIL PROTECTED]
Subject: Re: $r-prev is always defined

Jindo wrote:
 Hello,
 
 According to docs, $r-prev returns undef unless there is an internal
 redirect.  But to 
 my surprises, $r-prev is always defined, severely breaking down the
 code/flow logic 
 of my scripts.
 
 Here is what I have in /Index.cgi (My browser defaults to that page)
for
 debugging
 $r-log_error($r-prev()-uri());
 $r-log_error($r-uri());

I'd suspect that it's probably mod_dir (via DirectoryIndex) that's 
causing this (since it calls ap_internal_redirect, which sets $r-prev 
and $r-prev-uri).

I also suspect that if you called /Index.cgi directly, you'd get a 500 
(and $r-prev would be undef so $r-prev-uri would bomb).

HTH

--Geoff




Re: $r-prev is always defined

2002-09-09 Thread Geoffrey Young



Jindo wrote:
 Hello,
 
 Unfortunately, I did suspect the same before and called Index.cgi
 directly.  By calling it directly, $r-log_error($r-prev()-uri())
 still perfectly printed one line in error_log.

you must be doing something with internal redirects _someplace_.  I'm 
running CVS versions of both Apache and mod_perl and the below script 
gives me exactly what we all expect (both using Apache::Registry and 
modified as a standalone PerlHandler).

I'd try turning on mod_perl debug mode (assuming you built with a 
debugging perl):

PerlSetEnv MOD_PERL_TRACE all

and see if you can see the redirect taking place.

I'm sure that if r-prev were _always_ defined lots of stuff would be 
breaking for lots of people.  after all, what's in r-prev if there is 
no subrequest?  the main request was somehow copied into r-prev 
without anybody asking for it?

if you can't see an internal redirect anyplace and still think this is 
a bug, then I'd suggest stripping down your httpd.conf to a bare 
minimum and creating a test case that we can plug in and try in order 
to isolate the issue and see what's going on.

HTH

--Geoff

#!/usr/bin/perl

my $r = shift;

$r-send_http_header('text/plain');
print prev is defined\n if defined $r-prev;
print prev exists\n if $r-prev;
eval {
   print prev uri\n if $r-prev-uri;
};
print prev-uri blew up\n if $;
print all done\n;