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

Mark Stosberg mark at summersault.com
Sat Jun 21 10:53:56 EDT 2008


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. 

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\./;

The unpatched version once caused a problem for me because I depended on
CGI::Session's behavior of calling "flush()" automatically when that
object goes out of scope. 

Because of the circular reference, the object didn't go out of scope in
time, and the flush didn't happen. 

   Mark





More information about the cgiapp mailing list