I had a situation where a pnotes() key set in one phase had a value I
did not expect in a later phase. Here's a small module that I wrote
as a HeaderParserHandler to illustrate:
package Ii::Apache::pnotes;
use Apache::Constants 'OK';
sub handler {
my $r = shift;
$r->push_handlers('PerlFixupHandler' => \&other_phase);
my $n = 'I set this during the '.$r->current_callback." phase\n";
$r->notes('sample_note', $n);
printf STDERR '%s: %s', $r->current_callback(), $n;
$n = "I set this to something else before returning.\n";
return OK;
}
sub other_phase {
my $r = shift;
printf STDERR '%s: %s',
$r->current_callback(), $r->notes('sample_note');
return OK;
}
1;
__END__
...and here's what I get in my error_log:
PerlHeaderParserHandler: I set this during the PerlHeaderParserHandler phase
PerlFixupHandler: I set this to something else before returning.
If I s/pnotes/notes/ then I get what I expected:
PerlHeaderParserHandler: I set this during the PerlHeaderParserHandler phase
PerlFixupHandler: I set this during the PerlHeaderParserHandler phase
I had gotten into the habit of using pnotes() all the time no matter
what sort of value I was passing around, but it seems that if it's going
to be a regular scalar, notes() is how it must be, or I've got to be careful
not to change that variable after I set the pnotes() field. The behavior
surprized me because I wasn't passing a reference, yet pnotes() acts like
I did. In case anyone's wondering: apache 1.3.12, mod_perl 1.24.