Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit cfec72d

Browse files
committed
Merge branch 'hotfix/112' into develop
Forward port #112
2 parents 623c3b2 + 5bd9b2f commit cfec72d

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ All notable changes to this project will be documented in this file, in reverse
4848
- [#104](https://github.com/zendframework/zend-view/pull/104) fixes the
4949
`@method` annotation for the `Placeholder` view helper to use the correct case,
5050
fixing issues with method completion in IDEs.
51+
- [#112](https://github.com/zendframework/zend-view/pull/112) fixes an issue in
52+
the `PhpRendererStrategy` whereby absence of a response instance in the
53+
`ViewEvent` would lead to a fatal error.
5154

5255
## 2.8.1 - 2016-06-30
5356

src/Strategy/PhpRendererStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public function selectRenderer(ViewEvent $e)
103103
public function injectResponse(ViewEvent $e)
104104
{
105105
$renderer = $e->getRenderer();
106-
if ($renderer !== $this->renderer) {
106+
$response = $e->getResponse();
107+
if ($renderer !== $this->renderer || $response === null) {
107108
return;
108109
}
109110

110111
$result = $e->getResult();
111-
$response = $e->getResponse();
112112

113113
// Set content
114114
// If content is empty, check common placeholders to determine if they are

test/Helper/HeadMetaTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ public function testCharsetPosition()
434434
$this->assertEquals(
435435
'<meta charset="utf-8">' . PHP_EOL
436436
. '<meta property="description" content="foobar">',
437-
$view->plugin('headMeta')->toString());
437+
$view->plugin('headMeta')->toString()
438+
);
438439
}
439440

440441
/**

test/Strategy/PhpRendererStrategyTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class PhpRendererStrategyTest extends TestCase
2121
{
2222
use EventListenerIntrospectionTrait;
2323

24+
/** @var PhpRendererStrategy */
25+
private $strategy;
26+
2427
public function setUp()
2528
{
2629
$this->renderer = new PhpRenderer;
@@ -168,4 +171,14 @@ public function testDetachesListeners()
168171
$listeners = iterator_to_array($this->getListenersForEvent('response', $events));
169172
$this->assertCount(0, $listeners);
170173
}
174+
175+
public function testInjectResponseWorksWithAnEventWithNoResponse()
176+
{
177+
$e = new ViewEvent();
178+
$e->setRenderer($this->strategy->getRenderer());
179+
180+
$this->strategy->injectResponse($e);
181+
182+
$this->assertNull($e->getResponse());
183+
}
171184
}

0 commit comments

Comments
 (0)