perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <>
Subject Re: The evility of $r->status
Date Fri, 19 May 2006 19:29:01 GMT
Kjetil Kjernsmo wrote:
> Hi all!
> We have a bunch of old scripts that set $r->status explicitly. For 
> handlers, that's deprecated and unnecessary, but I understand that was 
> the usual way to do it in registry scripts in the old days of mp1. 
> What is not clear to me is if this is evil for scripts under mp2. We're 
> seeing some weird behavior sometimes, and this was under my suspicion, 
> but I don't quite know what to do about it (since I usually write 
> handlers myself) and I wouldn't want to get into all that old 
> code... :-)
> So, is the use of $r->status evil for Registry scripts under mp2, and if 
> so, what should be done to rewrite them?

it's the same as mp1.  note that with both mp1 and mp2, using $r->status
in registry scripts is merely a hack

    # handlers shouldn't set $r->status but return it, so we reset the
    # status after running it
    my $old_status = $self->{REQ}->status;
    my $rc = $self->run;
    my $new_status = $self->{REQ}->status($old_status);
    return ($rc == Apache2::Const::OK && $old_status != $new_status)
        ? $new_status
        : $rc;

so, basically $r->status is used to communicate the registry handler
return code, not really set r->status over in C-land (as it would be if
you called it from a normal handler).



View raw message