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

Do not cast request handlers implementing middleware to RequestHandlerMiddleware #646

Conversation

weierophinney
Copy link
Member

Per #645, MiddlewareContainer::get() was incorrectly casting middleware that also implemented RequestHandlerInterface to RequestHandlerMiddleware. This particularly affected Zend\Stratigility\MiddlewarePipe instances, as they implement both interfaces; if the last middleware in a pipeline called on the handler, users would then encounter a "pipeline exhausted" error, because it would be invoked as a handler, and thus have no reference to the application's pipeline.

This change verifies that the request handler does not also implement MiddlewareInterface before casting.

Fixes #645

…erMiddleware`

Per zendframework#645, `MiddlewareContainer::get()` was incorrectly casting
middleware that also implemented `RequestHandlerInterface` to
`RequestHandlerMiddleware`. This particularly affected
`Zend\Stratigility\MiddlewarePipe` instances, as they implement both
interfaces; if the last middleware in a pipeline called on the handler,
users would then encounter a "pipeline exhausted" error, because it
would be invoked as a handler, and thus have no reference to the
application's pipeline.

This change verifies that the request handler does not also implement
`MiddlewareInterface` before casting.
Copy link
Member

@michalbundyra michalbundyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@weierophinney weierophinney merged commit 6bad82f into zendframework:master Nov 8, 2018
weierophinney added a commit that referenced this pull request Nov 8, 2018
weierophinney added a commit that referenced this pull request Nov 8, 2018
@weierophinney weierophinney deleted the hotfix/645-container-pipeline branch November 8, 2018 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants