Skip to content

Commit

Permalink
fixed bug where "handler" was not an allowed name for controller methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 17, 2014
1 parent 36f64ab commit 8a40c41
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,7 +1,8 @@

5.62 2014-11-17
5.62 2014-11-18
- Fixed bug in Mojolicious::Routes::Pattern where optional placeholders in
nested routes would sometimes not work correctly.
- Fixed bug where "handler" was not an allowed name for controller methods.

5.61 2014-11-14
- Moved entities.txt into the DATA section of Mojo::Util to avoid
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojolicious.pm
Expand Up @@ -157,13 +157,13 @@ sub new {
# Default to controller and application namespace
my $r = $self->routes->namespaces(["@{[ref $self]}::Controller", ref $self]);

# Hide controller attributes/methods and "handler"
# Hide controller attributes/methods
$r->hide(qw(app continue cookie every_cookie every_param));
$r->hide(qw(every_signed_cookie finish flash handler helpers match on));
$r->hide(qw(param redirect_to render render_exception render_later));
$r->hide(qw(render_maybe render_not_found render_to_string rendered req));
$r->hide(qw(res respond_to send session signed_cookie stash tx url_for));
$r->hide(qw(validation write write_chunk));
$r->hide(qw(every_signed_cookie finish flash helpers match on param));
$r->hide(qw(redirect_to render render_exception render_later render_maybe));
$r->hide(qw(render_not_found render_to_string rendered req res respond_to));
$r->hide(qw(send session signed_cookie stash tx url_for validation write));
$r->hide(qw(write_chunk));

# DEPRECATED in Tiger Face!
$r->hide('render_static');
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -167,15 +167,15 @@ sub _controller {
my $class = ref $new;
my $app = $old->app;
my $log = $app->log;
if (my $sub = $new->can('handler')) {
if ($new->isa('Mojo')) {
$log->debug(qq{Routing to application "$class".});

# Try to connect routes
if (my $sub = $new->can('routes')) {
my $r = $new->$sub;
weaken $r->parent($old->match->endpoint)->{parent} unless $r->parent;
}
$new->$sub($old);
$new->handler($old);
$old->stash->{'mojo.routed'}++;
}

Expand Down
1 change: 0 additions & 1 deletion t/mojolicious/app.t
Expand Up @@ -106,7 +106,6 @@ ok $t->app->routes->is_hidden('every_param'), 'is hidden';
ok $t->app->routes->is_hidden('every_signed_cookie'), 'is hidden';
ok $t->app->routes->is_hidden('finish'), 'is hidden';
ok $t->app->routes->is_hidden('flash'), 'is hidden';
ok $t->app->routes->is_hidden('handler'), 'is hidden';
ok $t->app->routes->is_hidden('has'), 'is hidden';
ok $t->app->routes->is_hidden('helpers'), 'is hidden';
ok $t->app->routes->is_hidden('match'), 'is hidden';
Expand Down
5 changes: 1 addition & 4 deletions t/mojolicious/lib/SingleFileTestApp.pm
Expand Up @@ -16,9 +16,6 @@ sub startup {
push @{$self->renderer->classes}, 'SingleFileTestApp::Foo';
push @{$self->static->classes}, 'SingleFileTestApp::Foo';

# Allow redispatching controller
push @{$self->routes->base_classes}, 'Mojo::Base';

# Helper route
$self->routes->route('/helper')->to(
cb => sub {
Expand All @@ -32,7 +29,7 @@ sub startup {
}

package SingleFileTestApp::Redispatch;
use Mojo::Base -base;
use Mojo::Base 'Mojo';

sub handler {
my ($self, $c) = @_;
Expand Down

0 comments on commit 8a40c41

Please sign in to comment.