I did some more tweaking to ModPerl::RegistryCooker. I think my previous implementation would have problems when the script has changed the status and then failed (the failure would be ignored then). Please verify that this is still good (the test suite passes, but it's not exhaustive).

# 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 ($old_status != $new_status && $rc == Apache::OK)
? $new_status
: $rc;

The logic here is simpler:

1. store the new status code (just in case the script has changed it)
2. reset the status code to the one before the script execution
3. if the script has attempted to change the status by itself and the execution status is Apache::OK return that new status. Otherwise return the execution status (which will be either Apache::OK or Apache::SERVER_ERROR)

So if that's valid, here are the suggested patches to bring all 3 implementations in sync (David, please check that both Registry and PerlRun work for you):

Index: lib/Apache/Registry.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/Registry.pm,v
retrieving revision 1.34
diff -u -r1.34 Registry.pm
--- lib/Apache/Registry.pm 23 May 2002 04:21:07 -0000 1.34
+++ lib/Apache/Registry.pm 5 Feb 2003 06:14:00 -0000
@@ -169,7 +169,8 @@
# return REDIRECT;
# }
# }
- return $r->status($old_status);
+ my $new_status = $r->status($old_status);
+ return $old_status != $new_status ? $new_status : OK;
} else {
xlog_error($r, "$filename not found or unable to stat");
return NOT_FOUND unless $Debug && $Debug & 2;
Index: lib/Apache/RegistryNG.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/RegistryNG.pm,v
retrieving revision 1.8
diff -u -r1.8 RegistryNG.pm
--- lib/Apache/RegistryNG.pm 24 Mar 2002 22:06:39 -0000 1.8
+++ lib/Apache/RegistryNG.pm 5 Feb 2003 06:14:00 -0000
@@ -56,7 +56,7 @@
my $pr_status = $pr->status;
$r->status($old_status);

- return ($rc != OK) ? $rc : $pr_status;
+ return ($rc == OK && $old_status != $new_status) ? $pr_status : $rc;
}

1;


__________________________________________________________________
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

Reply via email to