Index: tests/Zend/Layout/PluginTest.php =================================================================== --- tests/Zend/Layout/PluginTest.php (wersja 18502) +++ tests/Zend/Layout/PluginTest.php (kopia robocza) @@ -177,6 +177,33 @@ $this->assertNotContains('Site Layout', $body); } + public function testPostDispatchDoesNotRenderLayoutWhenResponseRedirected() + { + $front = Zend_Controller_Front::getInstance(); + $request = new Zend_Controller_Request_Simple(); + $response = new Zend_Controller_Response_Cli(); + + $request->setDispatched(true); + $response->setHttpResponseCode(302); + $response->setBody('Application content'); + $front->setRequest($request) + ->setResponse($response); + + $layout = Zend_Layout::startMvc(); + $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts') + ->setLayout('plugin.phtml') + ->setMvcSuccessfulActionOnly(false) + ->disableInflector(); + + $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout'); + $plugin->setResponse($response); + $plugin->postDispatch($request); + + $body = $response->getBody(); + $this->assertContains('Application content', $body); + $this->assertNotContains('Site Layout', $body); + } + public function testPostDispatchDoesNotRenderLayoutWhenLayoutDisabled() { $front = Zend_Controller_Front::getInstance(); Index: library/Zend/Layout/Controller/Plugin/Layout.php =================================================================== --- library/Zend/Layout/Controller/Plugin/Layout.php (wersja 18502) +++ library/Zend/Layout/Controller/Plugin/Layout.php (kopia robocza) @@ -112,6 +112,7 @@ // Return early if forward detected if (!$request->isDispatched() + || $this->getResponse()->isRedirect() || ($layout->getMvcSuccessfulActionOnly() && (!empty($helper) && !$helper->isActionControllerSuccessful()))) {