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

Ensure invokable, duck-typed, class-based interop middleware works #467

Conversation

weierophinney
Copy link
Member

When using invokable, class-based, duck-typed interop middleware that NOT composed in the DI container, MarshalMiddlewareTrait::marshalInvokableMiddleware was incorrectly wrapping this in a CallableMiddlewareWrapper instead of a CallableInteropMiddlewareWrapper; when such middleware was invoked, it was thus incorrectly being passed a response instead of a delegate, leading to a fatal error.

This patch adds a unit test to validate usage, and fixes an incorrect test in the process.

Fixes an issue reported by @robertbasic.

Based on an issue reported by @robertbasic. He reported that when you
compose invokable class-based middleware that duck-types the
`MiddlewareInterface`, Expressive raises an error; further, this only
happens if the middleware is not composed in the container. This patch
proposes a test case for that scenario.
Adds logic to `MarshalMiddlewareTrait::marshalInvokableMiddleware()` to
wrap callable interop middleware in a `CallableInteropMiddlewareWrapper`
instead of a `CallableMiddlewareWrapper`. Doing so highlighted a
problematic test in `MarshalMiddlewareTraitTest` as well, which has now
been corrected.
@weierophinney weierophinney added this to the 2.0.2 milestone Mar 13, 2017
Copy link

@robertbasic robertbasic left a comment

Choose a reason for hiding this comment

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

I tested the patch with my app, works fine!

@weierophinney weierophinney merged commit a9d628b into zendframework:master Mar 13, 2017
weierophinney added a commit that referenced this pull request Mar 13, 2017
weierophinney added a commit that referenced this pull request Mar 13, 2017
@weierophinney weierophinney deleted the hotfix/robertbasic-callable-interop-middleware branch March 13, 2017 14:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants