Dmitri Tikhonov wrote:
I upgraded to 1.99.08 a couple of days ago and noticed strange behavior in my CGI scripts that run under ModPerl::Registry -- in 1.99.07 they worked fine. In 1.99.08, however, every single one of my scripts has this appended to its standard output:As you've figured out my original bug fix was wrong, since it broke other cases. We need more tests to avoid this kind of bugs in the future. it seems that Apache::Registry and Apache::PerlRun handle the return codes differently. So without covering all possible cases I'm not sure what's the best approach. Can you please try the following patch and let me know if it works for you? Thanks.
(it's really only the first chunk that tries to fix the bug, the rest are just some fixes to sync with 1.0.)
Index: lib/ModPerl/RegistryCooker.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v
retrieving revision 1.27
diff -u -r1.27 RegistryCooker.pm
--- lib/ModPerl/RegistryCooker.pm 6 Jan 2003 10:42:38 -0000 1.27
+++ lib/ModPerl/RegistryCooker.pm 17 Jan 2003 06:15:14 -0000
@@ -163,9 +163,13 @@
# handlers shouldn't set $r->status but return it
my $old_status = $self->[REQ]->status;
my $rc = $self->run;
- $self->[REQ]->status($old_status);
+ my $new_status = $self->[REQ]->status;
- return ($rc != Apache::OK) ? $rc : $self->[STATUS];
+ # only if the script has changed the status, reset to the old
+ # status and return the new status
+ return $old_status != $new_status
+ ? $self->[REQ]->status($old_status)
+ : $rc;
}
#########################################################################
@@ -185,11 +189,11 @@
$self->set_script_name;
$self->chdir_file;
- my $rc = Apache::OK;
my $cv = \&{"$package\::handler"};
my %orig_inc = %INC;
+ my $rc;
{ # run the code and preserve warnings setup when it's done
no warnings;
eval { $rc = $cv->($r, @_) };
@@ -208,11 +212,11 @@
#XXX: $self->chdir_file("$Apache::Server::CWD/");
- if ( ($rc = $self->error_check) != Apache::OK) {
- return $rc;
+ if ( (my $err_rc = $self->error_check) != Apache::OK) {
+ return $err_rc;
}
- return Apache::OK;
+ return wantarray ? (Apache::OK, $rc) : Apache::OK;
}
__________________________________________________________________
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]
