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

Commit 8915070

Browse files
committed
Merge branch 'hotfix/447'
Close #447 Fixes #446
2 parents 985cff6 + 803f449 commit 8915070

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 1.1.1 - 2017-02-14
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Deprecated
12+
13+
- Nothing.
14+
15+
### Removed
16+
17+
- Nothing.
18+
19+
### Fixed
20+
21+
- [#447](https://github.com/zendframework/zend-expressive/pull/447) fixes an
22+
error in the `ApplicationFactory` that occurs when the `config` service is an
23+
`ArrayObject`. Prior to the fix, `ArrayObject` configurations would cause a
24+
fatal error when injecting the pipeline and/or routes.
25+
526
## 1.1.0 - 2017-02-13
627

728
### Added

src/Container/ApplicationFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Zend\Expressive\Container;
99

10+
use ArrayObject;
1011
use Interop\Container\ContainerInterface;
1112
use SplPriorityQueue;
1213
use Zend\Diactoros\Response\EmitterInterface;
@@ -156,6 +157,7 @@ class ApplicationFactory
156157
public function __invoke(ContainerInterface $container)
157158
{
158159
$config = $container->has('config') ? $container->get('config') : [];
160+
$config = $config instanceof ArrayObject ? $config->getArrayCopy() : $config;
159161

160162
$router = $container->has(RouterInterface::class)
161163
? $container->get(RouterInterface::class)
@@ -513,10 +515,10 @@ private function marshalNoopFinalHandler(ContainerInterface $container)
513515
* Create default FinalHandler with options configured under the key final_handler.options.
514516
*
515517
* @param ContainerInterface $container
516-
* @param array|\ArrayObject $config
518+
* @param array $config
517519
* @return callable|FinalHandler
518520
*/
519-
private function marshalLegacyFinalHandler(ContainerInterface $container, $config)
521+
private function marshalLegacyFinalHandler(ContainerInterface $container, array $config)
520522
{
521523
if ($container->has('Zend\Expressive\FinalHandler')) {
522524
return $container->get('Zend\Expressive\FinalHandler');

test/Container/ApplicationFactoryIntegrationTest.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace ZendTest\Expressive\Container;
1111

12+
use ArrayObject;
1213
use PHPUnit_Framework_TestCase as TestCase;
1314
use Prophecy\Argument;
1415
use Psr\Http\Message\ServerRequestInterface;
@@ -50,7 +51,12 @@ public function setUp()
5051
$this->injectServiceInContainer($this->container, EmitterInterface::class, $this->emitter->reveal());
5152
}
5253

53-
public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNextWithError()
54+
/**
55+
* @dataProvider configType
56+
*
57+
* @param string $type
58+
*/
59+
public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNextWithError($type)
5460
{
5561
$always = function ($request, $response, $next) {
5662
$response = $next($request, $response);
@@ -121,6 +127,11 @@ public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNe
121127
],
122128
],
123129
];
130+
131+
if ($type !== 'array') {
132+
$config = new $type($config);
133+
}
134+
124135
$this->injectServiceInContainer($this->container, 'config', $config);
125136

126137
$app = $this->factory->__invoke($this->container->reveal());
@@ -139,7 +150,12 @@ public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNe
139150
$this->assertEquals('Error middleware called', (string) $response->getBody());
140151
}
141152

142-
public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWithError()
153+
/**
154+
* @dataProvider configType
155+
*
156+
* @param string $type
157+
*/
158+
public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWithError($type)
143159
{
144160
$always = function ($request, $response, $next) {
145161
$response = $next($request, $response);
@@ -209,6 +225,11 @@ public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWi
209225
],
210226
],
211227
];
228+
229+
if ($type !== 'array') {
230+
$config = new $type($config);
231+
}
232+
212233
$this->injectServiceInContainer($this->container, 'config', $config);
213234

214235
$app = $this->factory->__invoke($this->container->reveal());
@@ -226,4 +247,12 @@ public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWi
226247
$this->assertEquals('needs-auth', $response->getHeaderLine('X-Route-Result'));
227248
$this->assertEquals('Error middleware called', (string) $response->getBody());
228249
}
250+
251+
public function configType()
252+
{
253+
return [
254+
[ArrayObject::class],
255+
['array'],
256+
];
257+
}
229258
}

0 commit comments

Comments
 (0)