Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 7844 invoked from network); 6 Nov 2007 16:48:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2007 16:48:23 -0000 Received: (qmail 18887 invoked by uid 500); 6 Nov 2007 16:48:11 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 18874 invoked by uid 500); 6 Nov 2007 16:48:10 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 18863 invoked by uid 99); 6 Nov 2007 16:48:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2007 08:48:10 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [76.96.62.17] (HELO QMTA10.westchester.pa.mail.comcast.net) (76.96.62.17) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2007 16:48:12 +0000 Received: from OMTA02.westchester.pa.mail.comcast.net ([76.96.62.19]) by QMTA10.westchester.pa.mail.comcast.net with smtp id 9U451Y0070QuhwU0002q00; Tue, 06 Nov 2007 16:47:50 +0000 Received: from helm.modperlcookbook.net ([69.142.98.87]) by OMTA02.westchester.pa.mail.comcast.net with comcast id 9Unq1Y00B1t7PYM0000000; Tue, 06 Nov 2007 16:47:50 +0000 X-Authority-Analysis: v=1.0 c=1 a=eNcD7ojaAAAA:8 a=jRz7qBaSZinbCEK8MUgA:9 a=znPqDQXGPADR3REscSB09809O7QA:4 a=f-ADshzQSboA:10 Message-ID: <47309AB2.6040102@modperlcookbook.org> Date: Tue, 06 Nov 2007 11:47:46 -0500 From: Geoffrey Young User-Agent: Thunderbird 2.0.0.5 (X11/20070727) MIME-Version: 1.0 To: dev@perl.apache.org CC: Tim.Bunce@pobox.com Subject: [Fwd: [rt.cpan.org #30061] $r->pnotes stores aliases not copies so is subject to action at a distance] X-Enigmail-Version: 0.95.4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org so, I've been thinking a bit about this and I think I recall the original reasoning way back when... my $obj = $class->new(); $r->pnotes(OBJ => $obj); I am almost certain that this was the original use case for pnotes as I dig into my mind and recall the time on the list where folks were like "wow! we can pass a perl scalar around the request." what this, um, feature allows users to do is alter the underlying object without re-storing it along the way: $obj->update_user(); # next guy to pull it from pnotes gets the current state over the years I think we will find that people do that kind of thing _all the time_ with pnotes. anyway, I'm not arguing here, but I was trying to figure out why it was done this way in the first place - doug didn't just do stuff at random, but tended to add features that were dwimmy for the use-cases of the dot-com era :) --Geoff -------- Original Message -------- Subject: [rt.cpan.org #30061] $r->pnotes stores aliases not copies so is subject to action at a distance Date: Tue, 06 Nov 2007 11:31:51 -0500 From: Tim_Bunce via RT Reply-To: bug-mod_perl@rt.cpan.org To: undisclosed-recipients:; References: Queue: mod_perl Ticket I've just been bitten by this bug again! What's wrong with this code: sub foo { my ($r, $status, $why) = @_; $r->pnotes('foo', ($why) ? "$status:$why" : $status); return; } Nothing, except it doesn't work as expected due to this pnotes bug: If the same code is called in a sub-request then the pnote of $r->prev is magically updated at a distance to the same value! Try explain why that is to anyone not deeply familar with perl internals! The fix is to avoid pnotes taking a ref to the invisible op_targ embededed in the code by passing a simple lexical variable as the actual argument. That can be done in-line like this: sub mark_as_internally_redirected { my ($r, $status, $why) = @_; $r->pnotes('foo', my $tmp = (($why) ? "$status:$why" : $status)); return; } At the very least the docs need a big warning that the second argument to the pnotes method should only be a simple lexical variable. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org For additional commands, e-mail: dev-help@perl.apache.org