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

Deprecate Http subnamespace #70

Conversation

weierophinney
Copy link
Member

Per the RFC on removing the request and response decorators, this patch deprecates them for the upcoming 1.3 release.

The following changes were made:

Deprecated

  • Zend\Stratigility\Http\Request
    • The "psr" request is now injected with an additional attribute, originalRequest, allowing retrieval using standard PSR-7 methods.
    • Additionally, the methods getCurrentRequest() and getOriginalRequest() now emit deprecation notices.
  • Zend\Stratigility\Http\ResponseInterface
    • Additionally, the methods write(), end(), isComplete(), and getOriginalResponse() now emit deprecation notices.
  • Zend\Stratigility\Http\Response

Changed

  • Zend\Stratigility\FinalHandler
    • now pulls the original request via the originalRequest attribute instead.
    • no longer decorates the response, and instead writes to the PSR-7 response body directly (vs via the response write() method).

Added

  • Zend\Stratigility\Middleware\OriginalMessages is middleware that will inject the request instance passed to deeper layers with three attributes:
    • originalRequest, representing the request provided to it
    • originalResponse, representing the response provided to it
    • originalUri, representing the URI composed by the request provided to it
      We now recommend that if you need any of these artifacts, you pipe this middleware as the first layer of your application.

When invoked, injects attributes into the request for each of:

- originalUri
- originalRequest
- originalResponse

and passes the new request on to `$next()`.

Updated Http\Request to:

- inject the `originalRequest` attribute into the stored "PSR" request,
  ensuring that access to that attribute will return the original
  request.

Updated FinalHandler:

- to check for the `originalRequest` attribute, instead of testing for
  `Http\Request` and calling `getOriginalRequest()`.
- to no longer cast the response to `Http\Response` when writing content
  to it; it now writes to the response body directly.
- to cast responses to `Http\Response` prior to triggering the `onerror`
  handler; this is done to ensure types remain the same, in case
  developers typehint on the Stratigility message types in their
  handlers.

Finally, updated the request/response class-level docblocks to refer to
the `OriginalMessages` middleware as a means for injecting the
attributes containing the original artifacts.
…vocations

This patch updates the codebase to trigger deprecation notices when
invoking the various custom methods in the request and response
decorators. The notices detail why they are triggered, how to avoid
them, and link to relevant migration documentation.

Some tests needed updates. In particular, any tests that might produce
Stratigility HTTP message artifacts were updated to expect the
deprecation notices and skip over them if discovered. In a few cases,
methods from the messages were exercised by tests, and these were
updated to no longer do so.

A few expectations were also made on the Stratigility HTTP message
types; these were updated to the looser PSR-7 message types.
@weierophinney
Copy link
Member Author

The next in the 1.3/2.0 series of deprecations and improvements. Pinging @zendframework/community-review-team , @michaelmoussa , and @xtreamwayz for review.

Copy link

@akrabat akrabat left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@weierophinney weierophinney merged commit 227406f into zendframework:develop Sep 30, 2016
weierophinney added a commit that referenced this pull request Sep 30, 2016
weierophinney added a commit that referenced this pull request Sep 30, 2016
Forward port #70 to dev-2.0.0

Conflicts:
	doc/book/migration/to-v2.md
	src/FinalHandler.php
	test/FinalHandlerTest.php
	test/MiddlewarePipeTest.php
@weierophinney weierophinney deleted the feature/decorator-deprecation branch September 30, 2016 16:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
v2
Complete
Development

Successfully merging this pull request may close these issues.

None yet

3 participants