NAME
Apache2::SafePnotes - a safer replacement for Apache2::RequestUtil::pnotes
SYNOPSIS
use Apache2::SafePnotes;
use Apache2::SafePnotes qw/pnotes/;
use Apache2::SafePnotes qw/whatever/;
DESCRIPTION
This module cures a problem with Apache2::RequestUtil::pnotes. This function stores perl variables making them accessible from various phases of the Apache request cycle.
Unfortunately, the function does not copy a passed variable but only increments its reference counter and saves a reference.
Thus, the following situation could lead to unexpected results:
my $v=1;
$r->pnotes( 'v'=>$v );
$v++;
my $x=$r->pnotes('v');
I'd expect $x to be 1 after that code snipped but it turns out to be 2. The same goes for the tied hash interface:
my $v=1;
$r->pnotes->{v}=$v;
$v++;
my $x=$r->pnotes->{v};
Even now $x is 2.
With Apache2::SafePnotes the problem goes away and $x will be 1 in both cases.
INTERFACE
This module must be use'd not require'd. It does it's work in an import function.
- use Apache2::SafePnotes
-
creates the function
Apache::RequestRec::safe_pnotesas a replacement forpnotes. The oldpnotesfunction is preserved just in case some code relies on the odd behavior. - use Apache2::SafePnotes qw/NAME/
-
creates the function
Apache::RequestRec::NAMEas a replacement forpnotes. Ifpnotesis passed as NAME the originalpnotesfunction is replaced by the safer one.
SEE ALSO
modperl2, Apache2::RequestUtil
AUTHOR
Torsten Foertsch, <torsten.foertsch@gmx.net>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Torsten Foertsch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 89:
You forgot a '=back' before '=head1'