Rename the actions attribute in Catalyt::Controller to _controller_actions to avoid...
Roland Lammel [Wed, 13 May 2009 18:25:30 +0000 (18:25 +0000)]
Changes
lib/Catalyst.pm
lib/Catalyst/Controller.pm
t/lib/TestApp/Controller/Keyword.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index 3a02976..e0d7e21 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Rename the actions attribute in Catalyt::Controller to _controller_actions to
+          avoid name clashes with application controller naming. (random)
         - Test for using Moose in components which have a non-Moose base class
           Fixed by 349cda in Moose 0.78 (t0m)
         - Fix deprecation message for Catalyst::Dispatcher to refer
index 62fc85b..9a75306 100644 (file)
@@ -2748,6 +2748,8 @@ phaylon: Robert Sedlacek <phaylon@dunkelheit.at>
 
 rafl: Florian Ragwitz <rafl@debian.org>
 
+random: Roland Lammel <lammel@cpan.org>
+
 sky: Arthur Bergman
 
 the_jester: Jesse Sheidlower
index bf082ec..8b391df 100644 (file)
@@ -29,7 +29,7 @@ has action_namespace =>
      predicate => 'has_action_namespace',
     );
 
-has actions =>
+has _controller_actions =>
     (
      is => 'rw',
      isa => 'HashRef',
@@ -41,7 +41,7 @@ sub BUILD {
     my $action  = delete $args->{action}  || {};
     my $actions = delete $args->{actions} || {};
     my $attr_value = $self->merge_config_hashes($actions, $action);
-    $self->actions($attr_value);
+    $self->_controller_actions($attr_value);
 }
 
 =head1 NAME
@@ -260,7 +260,7 @@ sub _parse_attrs {
     # superior while mantaining really high degree of compat
     my $actions;
     if( ref($self) ) {
-        $actions = $self->actions;
+        $actions = $self->_controller_actions;
     } else {
         my $cfg = $self->config;
         $actions = $self->merge_config_hashes($cfg->{actions}, $cfg->{action});
diff --git a/t/lib/TestApp/Controller/Keyword.pm b/t/lib/TestApp/Controller/Keyword.pm
new file mode 100644 (file)
index 0000000..6a7043b
--- /dev/null
@@ -0,0 +1,18 @@
+package TestApp::Controller::Keyword;
+
+use strict;
+use base 'Catalyst::Controller';
+
+#
+# Due to 'actions' being used as an attribute up to cat 5.80003 using this name
+# for an action causes a weird error, as this would be called during BUILD time
+# of the Catalyst::Controller class
+#
+
+sub actions : Local {
+    my ( $self, $c ) = @_;
+    die("Call to controller action method without context! Probably naming clash") unless $c;
+    $c->res->output("Test case for using 'actions' as a catalyst action name\n");
+}
+
+1;