Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dancer CPAN distribution.

Report information
The Basics
Id: 57158
Status: resolved
Priority: 0/
Queue: Dancer

People
Owner: Nobody in particular
Requestors: stephane [...] shimaore.net
Cc:
AdminCc:

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



Subject: route_cache does not work with multiple parameters
I've been chasing what I found was a bug in my code since yesterday, but it seems it would be a bug in the route_cache handler. Here is an example exhibiting the issue: #!/usr/bin/env perl use Dancer; set route_cache => 1; get '/number/:cluster/:category' => sub { "Cluster: ".params->{cluster}." category: ".params->{category}; }; post '/number/:cluster/:category' => sub { "Cluster: ".params->{cluster}." category: ".params->{category}; }; dance(); Accessing http://127.0.0.1:3000/number/foo/bar http://127.0.0.1:3000/number/foo/boo http://127.0.0.1:3000/number/foo/bar in that order will show that on the third attempt the parameters are incorrect. Running the same script with set route_cache => 0; works as expected.
From: stephane [...] shimaore.net
This is a test script (for t/03_route_handler) which exhibits the issue. (Some tests are commented out due to a separate issue with routing of queries that have both named and splat parameters.)
Subject: 24_multiple_params.t
use strict; use warnings; use Test::More tests => 26*2+9, import => ['!pass']; use t::lib::TestUtils; use Dancer ':syntax'; use Dancer::Route; use Dancer::Config 'setting'; { ok(get('/' => sub { 'index' }), 'first route set'); ok(get('/name/:name' => sub { params->{name} }), 'second route set'); ok(get('/name/:name/:location' => sub { params->{name} }), 'third route set'); # ok(get('/name/:name/:location/*' => sub { [params->{name},splat] }), 'third route set'); ok(get('/location/:location' => sub { params->{location} }), 'fourth route set'); ok(get('/location/:name/:location' => sub { params->{location} }), 'fifth route set'); # ok(get('/location/:name/:location/*' => sub { [params->{location},splat] }), 'fifth route set'); ok(post('/name/:name' => sub { params->{name} }), 'sixth route set'); ok(post('/name/:name/:location' => sub { params->{name} }), 'seventh route set'); ok(post('/location/:location' => sub { params->{location} }), 'eigth route set'); ok(post('/location/:name/:location' => sub { params->{location} }), 'ninth route set'); } my @tests = ( {method => 'GET', path => '/', expected => 'index'}, {method => 'GET', path => '/name/bob', expected => 'bob'}, {method => 'GET', path => '/name/bill', expected => 'bill'}, {method => 'GET', path => '/name/bob', expected => 'bob'}, # {method => 'GET', path => '/name/bob/paris/wine', expected => ['bob','wine'] }, # {method => 'GET', path => '/name/bob/dublin/beer', expected => ['bob','beer'] }, # {method => 'GET', path => '/name/bob/paris/wine', expected => ['bob','wine'] }, # {method => 'GET', path => '/name/bill/paris/wine', expected => ['bill','wine'] }, # {method => 'GET', path => '/name/bill/dublin/beer', expected => ['bill','beer'] }, # {method => 'GET', path => '/name/bill/paris/wine', expected => ['bill','wine'] }, # {method => 'GET', path => '/name/bob/paris/today', expected => ['bob','today'] }, # {method => 'GET', path => '/name/bob/dublin/now', expected => ['bob','now'] }, # {method => 'GET', path => '/name/bob/paris/tomorrow', expected => ['bob','tomorrow'] }, {method => 'GET', path => '/name/bob/paris', expected => 'bob' }, {method => 'GET', path => '/name/bob/dublin', expected => 'bob' }, {method => 'GET', path => '/name/bob/paris', expected => 'bob' }, {method => 'GET', path => '/name/bill/paris', expected => 'bill' }, {method => 'GET', path => '/name/bill/dublin', expected => 'bill' }, {method => 'GET', path => '/name/bill/paris', expected => 'bill' }, {method => 'GET', path => '/name/bob/paris', expected => 'bob' }, {method => 'GET', path => '/name/bob/dublin', expected => 'bob' }, {method => 'GET', path => '/name/bill/paris', expected => 'bill' }, {method => 'GET', path => '/name/bill/dublin', expected => 'bill' }, {method => 'GET', path => '/location/paris', expected => 'paris'}, {method => 'GET', path => '/location/dublin', expected => 'dublin'}, {method => 'GET', path => '/location/paris', expected => 'paris'}, {method => 'GET', path => '/location/bob/paris', expected => 'paris' }, {method => 'GET', path => '/location/bob/dublin', expected => 'dublin' }, {method => 'GET', path => '/location/bob/paris', expected => 'paris' }, # {method => 'GET', path => '/location/bob/paris/wine', expected => ['paris','wine'] }, # {method => 'GET', path => '/location/bob/dublin/beer', expected => ['dublin','beer'] }, # {method => 'GET', path => '/location/bob/paris/wine', expected => ['paris','wine'] }, {method => 'post', path => '/name/bob', expected => 'bob'}, {method => 'post', path => '/name/bob/paris', expected => 'bob' }, {method => 'post', path => '/location/paris', expected => 'paris'}, {method => 'post', path => '/location/bob/paris', expected => 'paris' }, {method => 'post', path => '/location/bob/dublin', expected => 'dublin' }, {method => 'post', path => '/location/bob/paris', expected => 'paris' }, ); setting route_cache => 1; foreach my $test (@tests) { my $method = $test->{method}; my $path = $test->{path}; my $expected = $test->{expected}; my $request = fake_request($method => $path); Dancer::SharedData->request($request); my $response = Dancer::Renderer::get_action_response(); ok( defined($response), "route handler found for path `$path'"); is_deeply( $response->{content}, $expected, "match data for path `$path' looks good"); }
Fixed in 1.1802, which was released. It needs to be reindexed, but that's a minor issue.