Skip Menu |

This queue is for tickets about the HTML-Mason CPAN distribution.

Report information
The Basics
Id: 16015
Status: resolved
Priority: 0/
Queue: HTML-Mason

People
Owner: Nobody in particular
Requestors: jesse [...] fsck.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Date: Mon, 21 Nov 2005 17:04:44 -0500
From: jesse <jesse [...] fsck.com>
To: bug-html-mason [...] rt.cpan.org
Subject: infinite loop in plugins
I'm sorry that the test case isn't in the form of a mason test script, but hopefull this is illustrative of the issue. Jesse #!/usr/bin/perl use warnings; use strict; my $server = MyApp::Server->new( 8081); $server->run; package MyApp::Server; use base qw/HTTP::Server::Simple::Mason/; sub mason_config { return ( comp_root => '/tmp/mason-pages', plugins => ['PluginDemo']); } sub handle_error { my $self = shift; my $err = shift; die $@; } package PluginDemo; use base qw/HTML::Mason::Plugin/; use Carp; sub start_request_hook { my ( $self, $context ) = @_; my $m = $context->request; unless ( $m->is_subrequest() ) { # can't get a base_comp in a plugin yet warn "my base comp is ".$m->base_comp; } } 1; --
When I run your script, I get an error (I made the directory /tmp/mason-pages/ and put an autohandler in it.), but I couldn't figure out the "infinite loop" part. Latest versions of HTML::Mason and HTTP::Server::Simple. error: could not find component for initial path '/' (component roots are: '/tmp/mason-pages') context: ... 200: $self->{out_method} = sub { $$bufref .= $_[0] }; 201: } 202: $self->{use_internal_component_caches} = 203: $self->{interp}->use_internal_component_caches; 204: $self->_initialize; 205: 206: return $self; 207: } 208: ... code stack: /usr/local/share/perl/5.8.7/HTML/Mason/Request.pm:204 /usr/local/share/perl/5.8.4/Class/Container.pm:275 /usr/local/share/perl/5.8.4/Class/Container.pm:353 /usr/local/share/perl/5.8.7/HTML/Mason/Interp.pm:329 /usr/local/share/perl/5.8.7/HTML/Mason/Interp.pm:323 /usr/local/share/perl/5.8.7/HTML/Mason/CGIHandler.pm:123 /usr/local/share/perl/5.8.7/HTML/Mason/CGIHandler.pm:73 /usr/local/share/perl/5.8.7/HTTP/Server/Simple/Mason.pm:84 /usr/local/share/perl/5.8.7/HTTP/Server/Simple/CGI.pm:92 /usr/local/share/perl/5.8.7/HTTP/Server/Simple.pm:327 /usr/local/share/perl/5.8.7/HTTP/Server/Simple.pm:265 /usr/local/share/perl/5.8.7/HTTP/Server/Simple.pm:229 masonpluginloop.pl:6
[jesse@fsck.com - Mon Nov 21 17:04:48 2005]: Show quoted text
> package PluginDemo; > use base qw/HTML::Mason::Plugin/; > use Carp; > sub start_request_hook { > my ( $self, $context ) = @_; > my $m = $context->request; > unless ( $m->is_subrequest() ) { > # can't get a base_comp in a plugin yet > warn "my base comp is ".$m->base_comp; > } > }
So the problem is that base_comp simply is not available inside this hook. I changed the code so it won't go into an infinite loop, rather it just returns false. I also documented that this does not work in HTML::Mason::Plugin.