Permalink
Browse files

Cloning the event protects the original event from changes that happe…

…n when we dispatch to the forward controller, namely the target of the event being changed to the forward controller.

Also, since we are cloning, there's no need to cache the routeMatch.
  • Loading branch information...
1 parent 8dd08e5 commit d0c093ac9cf6accaa49495d3e0987ddeec85bfcb @SocalNick SocalNick committed with May 23, 2012
Showing with 2 additions and 9 deletions.
  1. +2 −9 library/Zend/Mvc/Controller/Plugin/Forward.php
View
11 library/Zend/Mvc/Controller/Plugin/Forward.php
@@ -66,7 +66,7 @@ public function setMaxNestedForwards($maxNestedForwards)
*/
public function dispatch($name, array $params = null)
{
- $event = $this->getEvent();
+ $event = clone($this->getEvent());
$locator = $this->getLocator();
$scoped = false;
@@ -90,11 +90,8 @@ public function dispatch($name, array $params = null)
}
// Allow passing parameters to seed the RouteMatch with
- $cachedMatches = false;
if ($params) {
- $matches = new RouteMatch($params);
- $cachedMatches = $event->getRouteMatch();
- $event->setRouteMatch($matches);
+ $event->setRouteMatch(new RouteMatch($params));
}
if ($this->numNestedForwards > $this->maxNestedForwards) {
@@ -106,10 +103,6 @@ public function dispatch($name, array $params = null)
$this->numNestedForwards--;
- if ($cachedMatches) {
- $event->setRouteMatch($cachedMatches);
- }
-
return $return;
}

0 comments on commit d0c093a

Please sign in to comment.