Subject: | New release required for Catalyst 5.8 |
Since the release of Catalyst 5.8001401 the use of NEXT is deprecated in
favour of MRO::Compat and the standard is now to use Plugin::Captcha as
the config key. Attached is a patch that implements this
Subject: | Captcha.diff |
--- Catalyst/Plugin/Captcha.pm 2009-11-26 19:17:41.000000000 +0000
+++ Catalyst/Plugin/Captcha.pm 2009-11-26 20:17:39.000000000 +0000
@@ -5,25 +5,31 @@
use GD::SecurityImage;
use HTTP::Date;
-our $VERSION = '0.03';
+our $VERSION = '0.04';
+
+use MRO::Compat;
sub setup {
- my $c = shift;
+ my $c = shift;
+ my $config = $c->config->{ 'Plugin::Captcha' }
+ || delete $c->config->{captcha}; # Deprecated
+
+ $config->{session_name} ||= 'captcha_string';
+ $config->{captcha}->{new} ||= {};
+ $config->{captcha}->{create} ||= [];
+ $config->{captcha}->{particle} ||= [];
+ $config->{captcha}->{out} ||= {};
- $c->config->{captcha}->{session_name} = 'captcha_string';
- $c->config->{captcha}->{new} ||= {};
- $c->config->{captcha}->{create} ||= [];
- $c->config->{captcha}->{particle} ||= [];
- $c->config->{captcha}->{out} ||= {};
+ $c->config( 'Plugin::Captcha' => $config );
- return $c->NEXT::setup(@_);
+ return $c->next::method( @_ );
}
sub create_captcha {
- my $c = shift;
- my $conf = $c->config->{captcha};
-
+ my $c = shift;
+ my $conf = $c->config->{ 'Plugin::Captcha' };
my $image = GD::SecurityImage->new( %{ $conf->{new} } );
+
$image->random();
$image->create( @{ $conf->{create} } );
$image->particle( @{ $conf->{particle} } );
@@ -31,7 +37,7 @@
my ( $image_data, $mime_type, $random_string ) =
$image->out( %{ $conf->{out} } );
- $c->session->{ $c->config->{captcha}->{session_name} } = $random_string;
+ $c->session->{ $conf->{session_name} } = $random_string;
$c->res->headers->expires( time() );
$c->res->headers->header( 'Last-Modified' => HTTP::Date::time2str );
@@ -49,17 +55,20 @@
}
sub captcha_string {
- my $c = shift;
- return $c->session->{ $c->config->{captcha}->{session_name} };
+ my $c = shift;
+ my $conf = $c->config->{ 'Plugin::Captcha' };
+
+ return $c->session->{ $conf->{session_name} };
}
sub clear_captcha_string {
- my $c = shift;
- delete $c->session->{ $c->config->{captcha}->{session_name} };
+ my $c = shift;
+ my $conf = $c->config->{ 'Plugin::Captcha' };
+
+ delete $c->session->{ $conf->{session_name} };
return 1;
}
-
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
@@ -72,7 +81,7 @@
use Catalyst qw/Captcha/;
- MyApp->config->{captcha} = {
+ MyApp->config->{ 'Plugin::Captcha' } = {
session_name => 'captcha_string',
new => {
width => 80,