# This file documents the revision history for Perl extension Catalyst.
+5.90089_003 - TBA
+ - Fixed an issue where a delayed controller that did ACCEPT_CONTEXT would
+ raise an error when registering its actions.
+
5.90089_002 - 2015-04-17
- Changed the way we check for presence of Type::Tiny in a test case to be
more explicit in the version requirement. Hopefully a fix for reported
+++ /dev/null
-package Catalyst::Component::DelayedInstance;
-
-use Moose::Role;
-
-around 'COMPONENT', sub {
- my ($orig, $class, $app, $conf) = @_;
- my $method = $class->can('build_delayed_instance') ?
- 'build_delayed_instance' : 'COMPONENT';
-
- return bless sub { my $c = shift; $class->$method($app, $conf) }, $class;
-};
-
-our $SINGLE;
-
-sub ACCEPT_CONTEXT {
- my ($self, $c, @args) = @_;
- $c->log->warn("Component ${\$self->catalyst_component_name} cannot be called with arguments")
- if $c->debug and scalar(@args) > 0;
-
- return $SINGLE ||= $self->();
-}
-
-sub AUTOLOAD {
- my ($self, @args) = @_;
- my $method = our $AUTOLOAD;
- $method =~ s/.*:://;
-
- warn $method;
- use Devel::Dwarn;
- Dwarn \@args;
-
- return ($SINGLE ||= $self->())->$method(@args);
-}
-
-1;
-
-=head1 NAME
-
-Catalyst::Component::DelayedInstance - Moose Role for components which setup
-
-=head1 SYNOPSIS
-
- package MyApp::Model::Foo;
-
- use Moose;
- extends 'Catalyst::Model';
- with 'Catalyst::Component::DelayedInstance';
-
- sub build_per_application_instance {
- my ($class, $app, $config) = @_;
-
- $config->{bar} = $app->model("Baz");
- return $class->new($config);
- }
-
-=head1 DESCRIPTION
-
-Sometimes you want an application scoped component that nevertheless needs other
-application components as part of its setup. In the past this was not reliable
-since Application scoped components are setup in linear order. You could not
-call $app->model in a COMPONENT method and expect 'Foo' to be there. This role
-defers creating the application scoped instance until after your application is
-fully setup. This means you can now assume your other application scoped components
-(components that do COMPONENT but not ACCEPT_CONTEXT) are available as dependencies.
-
-Please note this means that your instance is not created until the first time its
-called in a request. As a result any errors with configuration will not show up
-until later in runtime. So there is a larger burden on your testing to make sure
-your application startup and runtime is accurate. Also note that even though your
-instance creation is deferred to request time, the request context is NOT given,
-but the application is (this means that you cannot depend on components that do
-ACCEPT_CONTEXT, since you don't have one...).
-
-=head1 ATTRIBUTES
-
-=head1 METHODS
-
-=head2 ACCEPT_CONTEXT
-
-=head2 AUTOLOAD
-
-=head1 SEE ALSO
-
-L<Catalyst::Component>,
-
-=head1 AUTHORS
-
-See L<Catalyst>.
-
-=head1 COPYRIGHT
-
-See L<Catalyst>.
-
-=cut
}
my @try_actions = @{$children->{$try_part}};
TRY_ACTION: foreach my $action (@try_actions) {
+
+
if (my $capture_attr = $action->attributes->{CaptureArgs}) {
my $capture_count = $action->number_of_captures|| 0;
else {
{
local $c->req->{arguments} = [ @{$c->req->args}, @parts ];
+warn $action;
+
next TRY_ACTION unless $action->match($c);
}
my $args_attr = $action->attributes->{Args}->[0];
# OR No parts and this expects 0
# The current best action might also be Args(0),
# but we couldn't chose between then anyway so we'll take the last seen
-
if (
!$best_action ||
@parts < @{$best_action->{parts}} ||
sub chained_one_args_0 : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_0') }
sub chained_one_args_1 : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_1') }
+ sub chained_one_args_2 : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_2') }
sub chained_zero_args_0 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_0') }
sub chained_zero_args_1 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_1') }
+ sub chained_zero_args_2 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_2') }
MyApp::Controller::Root->config(namespace=>'');
use Catalyst::Test 'MyApp';
{
my $res = request '/chain_base/capturearg/arg';
- is $res->content, 'chained_one_args_1', "request '/chain_base/capturearg/arg'";
+ is $res->content, 'chained_one_args_2', "request '/chain_base/capturearg/arg'";
}
{
my $res = request '/chain_base/capturearg';
- is $res->content, 'chained_zero_args_1', "request '/chain_base/capturearg'";
+ is $res->content, 'chained_zero_args_2', "request '/chain_base/capturearg'";
}
done_testing;
--- /dev/null
+use warnings;
+use strict;
+use Test::More;
+
+# Test case for reported issue when an action consumes JSON but a
+# POST sends nothing we get a hard error
+
+{
+ package MyApp::Controller::Root;
+ $INC{'MyApp/Controller/Root.pm'} = __FILE__;
+
+ use base 'Catalyst::Controller';
+
+ sub root :Chained(/) CaptureArgs(0) { }
+
+ sub get :GET Chained(root) PathPart('') Args(0) { }
+ sub post :POST Chained(root) PathPart('') Args(0) { }
+ sub put :PUT Chained(root) PathPart('') Args(0) { }
+
+ package MyApp;
+ use Catalyst;
+ MyApp->setup;
+}
+
+use HTTP::Request::Common;
+use Catalyst::Test 'MyApp';
+
+{
+ ok my $res = request POST 'root/';
+}
+
+done_testing();