From: John Napiorkowski Date: Mon, 24 Aug 2015 15:24:08 +0000 (-0500) Subject: resolve conflict X-Git-Tag: 5.90100~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=bde334da382a3d3ac58a63c9061639e712a02e0a;hp=59051400675390bde280ae6dc6cf500c7bd340cf resolve conflict --- diff --git a/Changes b/Changes index 64693c0..61c4c79 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ - Document using namespace::autoclean with controllers that have actions with type constraints. - Look for type constraints in super classes and consumed roles. + - Change the way the stash middleware works to no longer localize $psgi_env. 5.90098 - 2015-08-11 - Fix for RT#106373 (Issue when you try to install and also have an old diff --git a/lib/Catalyst/Middleware/Stash.pm b/lib/Catalyst/Middleware/Stash.pm index 4682da8..f874810 100644 --- a/lib/Catalyst/Middleware/Stash.pm +++ b/lib/Catalyst/Middleware/Stash.pm @@ -43,8 +43,8 @@ sub call { my $new_env = +{ %$env }; my %stash = %{ ($env->{+PSGI_KEY} || sub {})->() || +{} }; - $new_env->{+PSGI_KEY} = _create_stash( \%stash ); - return $self->app->($new_env); + $env->{+PSGI_KEY} = _create_stash( \%stash ); + return $self->app->($env); } =head1 NAME diff --git a/t/middleware-stash.t b/t/middleware-stash.t index baeb108..24b95f2 100644 --- a/t/middleware-stash.t +++ b/t/middleware-stash.t @@ -3,6 +3,28 @@ use strict; { + package MyMiddleware; + $INC{'MyMiddleware'} = __FILE__; + + our $INNER_VAR_EXPOSED; + + use base 'Plack::Middleware'; + + sub call { + my ($self, $env) = @_; + + my $res = $self->app->($env); + + return $self->response_cb($res, sub{ + my $inner = shift; + + $INNER_VAR_EXPOSED = $env->{inner_var_from_catalyst}; + + return; + }); + + } + package MyAppChild::Controller::User; $INC{'MyAppChild/Controller/User.pm'} = __FILE__; @@ -14,6 +36,8 @@ use strict; $c->stash->{inner} = "inner"; $c->res->body( "inner: ${\$c->stash->{inner}}, outer: ${\$c->stash->{outer}}"); + $c->req->env->{inner_var_from_catalyst} = 'station'; + is_deeply [sort {$a cmp $b} keys(%{$c->stash})], ['inner','outer'], 'both keys in stash'; } @@ -48,5 +72,6 @@ use Catalyst::Test 'MyAppParent'; my $res = request '/user/stash'; is $res->content, 'inner: inner, outer: outer', 'got expected response'; +is $MyMiddleware::INNER_VAR_EXPOSED, 'station', 'env does not get trampled'; done_testing;