Skip Menu |

This queue is for tickets about the CGI-Application-Plugin-MessageStack CPAN distribution.

Report information
The Basics
Id: 50400
Status: rejected
Priority: 0/
Queue: CGI-Application-Plugin-MessageStack

People
Owner: Nobody in particular
Requestors: AlexanderBecker [...] gmx.net
Cc:
AdminCc:

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



Subject: [patch] (c&p ready) for CGI::Application::Plugin::MessageStack
Date: Sun, 11 Oct 2009 21:11:39 +0200
To: <bug-cgi-application-plugin-messagestack [...] rt.cpan.org>
From: "Alexander Becker" <AlexanderBecker [...] gmx.net>
Hi! I opened a ticket at rt.cpan because of the bug, that CAP::MessageStack causes appes to die if they try to set the message_loop param in a template where it isn't defined. The crash concerns apps that use the default templating engine of CGI::Application (HTML::Template) with the (default) option die_on_bad_params => 1. There is now a solution: the plugin checks for HTML::Template and if it is used, it checks if the param is declared before setting it. There is code ready to copy & paste. All that changed is the new check, nothing else. Here is the code: [code] sub _pass_in_messages { my ( $self, $ht_params, $tmpl_params, $tmpl_file ) = @_; my $loop_name = $config{'-loop_param_name'} || 'CAP_Messages'; # -- check for HTML::Template and die_on_bad_params => 1 # TODO: omit check if die_on_bad_params => 0. if( $self->html_tmpl_class() eq 'HTML::Template' ) { my $t = undef; # -- copied from CGI::Application::load_tmpl() if( ref $tmpl_file eq 'SCALAR' ) { $t = HTML::Template->new( scalarref => $tmpl_file, %{$ht_params} ); } elsif ( ref $tmpl_file eq 'GLOB' ) { $t = HTML::Template->new( filehandle => $tmpl_file, %{$ht_params} ); } else { $t = HTML::Template->new( filename => $tmpl_file, %{$ht_params}); } return unless $t->query(name => $loop_name); } # get the proper messages and update $tmpl_params my $session = _check_for_session( $self ); my $current_runmode = $self->get_current_runmode(); my $message_stack = $session->param( '__CAP_MessageStack_Stack' ); my $messages = _filter_messages( $message_stack, { -scope => $current_runmode }, 1 ); $tmpl_params->{ $loop_name } = $messages if scalar( @$messages ); $self->clear_messages( -scope => $current_runmode ) if ( $config{'-automatic_clearing'} ); } [/code] Please apply this patch, as I make use of your module quite often (it's very useful, tanks for creating it). ATM I have to upload serval modified versions of CA::Plugins that are patched for compatibility with the default templating engine with default options. In my opinion, it shouldn't be that way :) Best regards, Alex
Dupe of issue # 48087