fixed reported c->state regression
John Napiorkowski [Wed, 8 Jun 2016 15:32:19 +0000 (10:32 -0500)]
Changes
lib/Catalyst/Dispatcher.pm

diff --git a/Changes b/Changes
index 3ea3fae..95255b3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -5,6 +5,10 @@
   - Changed how we compose traits onto the response, request, and stats class so
     that we compose just once at setup time (performance optimization).  Also added
     a debug screen at startup to display composed classes to help with debugging.
+  - Fixed a regressed caused by the changes we made to the way ->state works so that
+    now when you forward to an action and that action throws and exception, $c->state
+    is set to 0, instead of the value of the exeption (this is to be as indicated by
+    the documentation).
 
 5.90104 - 2016-04-04
   - Merged pull request #131, fix for noisy debug logs when used type constraints
index 46f41f8..d64b17e 100644 (file)
@@ -239,7 +239,7 @@ Documented in L<Catalyst>
 sub forward {
     my $self = shift;
     no warnings 'recursion';
-    $self->_do_forward(forward => @_);
+    return $self->_do_forward(forward => @_);
 }
 
 sub _do_forward {
@@ -261,6 +261,12 @@ sub _do_forward {
     no warnings 'recursion';
     $action->dispatch( $c );
 
+    #If there is an error, all bets off regarding state.  Documentation
+    #Specifies that when you forward, if there's an error you must expect
+    #state to be 0.
+    if( @{ $c->error }) {
+      $c->state(0);
+    }
     return $c->state;
 }