[cgiapp] Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

Rhesa Rozendaal perl at rhesa.com
Sat Jun 21 14:05:14 EDT 2008


Mark Stosberg wrote:
> CGI::Application::Plugin::HTDot currently creates a circular reference,
> by adding a reference back to the application object from the template
> object, which is already referenced by the application object. 

Where do you have a reference to the template object? Aren't your template 
objects local to the run mode?

> The line of code is this:
> 
>  $t->param( c => $self ) if $var =~ /^c\./;
> 
> Is it correct that it should actually be this?
> 
>   use Scalar::Util 'weaken';
>   $t->param( c => weaken($self) ) if $var =~ /^c\./;

I think it's a good idea in general. I certainly don't see a drawback. The 
template shouldn't use (or change!) the value of $self anyway, and weakrefs 
work just as well for objects.

rhesa


More information about the cgiapp mailing list