zendframework / zend-expressive

PSR-15 middleware in minutes!
BSD 3-Clause "New" or "Revised" License
711 stars 197 forks source link

Application::run incompatible with zend-stratigility 1.3 #390

Closed mryvlin closed 7 years ago

mryvlin commented 7 years ago

When invoking the Application, the third param is missing in the request, but as of zend-stratigility 1.3 the third param is now required. Here ist the error message:

[Fri Nov 11 11:30:33 2016] PHP Deprecated:  The third argument to Zend\Stratigility\MiddlewarePipe() ($out) will be required starting with Stratigility version 2; please see https://docs.zendframework.com/zend-stratigility/migration/to-v2/ for more details on how to update your application to remove this message. in /tmp/test-app/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php on line 101
[Fri Nov 11 11:30:33 2016] PHP Stack trace:
[Fri Nov 11 11:30:33 2016] PHP   1. {main}() /tmp/test-app/public/index.php:0
[Fri Nov 11 11:30:33 2016] PHP   2. Zend\Expressive\Application->run() /tmp/test-app/public/index.php:21
[Fri Nov 11 11:30:33 2016] PHP   3. Zend\Expressive\Application->__invoke() /tmp/test-app/vendor/zendframework/zend-expressive/src/Application.php:558
[Fri Nov 11 11:30:33 2016] PHP   4. Zend\Stratigility\MiddlewarePipe->__invoke() /tmp/test-app/vendor/zendframework/zend-expressive/src/Application.php:141
[Fri Nov 11 11:30:33 2016] PHP   5. trigger_error() /tmp/test-app/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:101
[Fri Nov 11 11:30:33 2016] PHP Deprecated:  The third argument to Zend\Stratigility\MiddlewarePipe() ($out) will be required starting with Stratigility version 2; please see https://docs.zendframework.com/zend-stratigility/migration/to-v2/ for more details on how to update your application to remove this message. in /tmp/test-app/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php on line 101
[Fri Nov 11 11:30:33 2016] PHP Stack trace:
[Fri Nov 11 11:30:33 2016] PHP   1. {main}() /tmp/test-app/public/index.php:0
[Fri Nov 11 11:30:33 2016] PHP   2. Zend\Expressive\Application->run() /tmp/test-app/public/index.php:21
[Fri Nov 11 11:30:33 2016] PHP   3. Zend\Expressive\Application->__invoke() /tmp/test-app/vendor/zendframework/zend-expressive/src/Application.php:558
[Fri Nov 11 11:30:33 2016] PHP   4. Zend\Stratigility\MiddlewarePipe->__invoke() /tmp/test-app/vendor/zendframework/zend-expressive/src/Application.php:141
[Fri Nov 11 11:30:33 2016] PHP   5. trigger_error() /tmp/test-app/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:101

For now the easiest solution I've found is to pass new NoopFinalHandler() as the third parameter, so that the method looks like following:

    public function run(ServerRequestInterface $request = null, ResponseInterface $response = null)
    {
        $request  = $request ?: ServerRequestFactory::fromGlobals();
        $response = $response ?: new Response();

        $response = $this($request, $response, new NoopFinalHandler());

        $emitter = $this->getEmitter();
        $emitter->emit($response);
    }
weierophinney commented 7 years ago

This is not technically an incompatibility. The application will still run; it will just emit deprecation notices.

That said, I'm working on a 1.0.1 release that will ensure that the code is both backwards compatible with earlier Stratigility versions, as well as compatible with the 1.3 series, and should have a patch in place shortly.