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

Releases: zendframework/zend-stratigility

zend-stratigility 3.2.0

12 Jun 15:23
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • #186 adds a safeguard to middleware pipes to prevent them from being called
    multiple times within the same middleware. As an example, consider the
    following middleware:

    public function process(
        ServerRequestInterface $request,
        RequestHandlerInterface $handler
    ) : Response Interface {
        $session = $request->getAttribute('session');
        if (! $session) {
            $response = $handler->handle($request);
        }
    
        // Inject another attribute before handling
        $response = $handler->handle($request->withAttribute(
            'sessionWasEnabled',
            true
        );
        return $response;
    }

    When using Stratigility, the $handler is an instance of
    Zend\Stratigility\Next, which encapsulates the middleware pipeline and
    advances through it on each call to handle().

    The example demonstrates a subtle error: the response from the first
    conditional should have been returned, but wasn't, which has led to invoking
    the handler a second time. This scenario can have unexpected behaviors,
    including always returning a "not found" response, or returning a response
    from a handler that was not supposed to execute (as an earlier middleware
    already returned early in the original call).

    These bugs are hard to locate, as calling handle() is a normal part of any
    middleware, and multiple conditional calls to it are a standard workflow.

    With this new version, Next will pass a clone of itself to the next
    middleware in the pipeline, and unset its own internal pipeline queue. Any
    subsequent requests to handle() within the same scope will therefore result
    in the exception Zend\Stratigility\Exception\MiddlewarePipeNextHandlerAlreadyCalledException.

    If you depended on calling $handler->handle() multiple times in succession
    within middleware, we recommend that you compose the specific pipeline(s)
    and/or handler(s) you wish to call as class dependencies.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

zend-stratigility 3.1.0

06 Feb 18:17
Compare
Choose a tag to compare

Added

  • #178 adds the class Zend\Stratigility\EmptyPipelineHandler, which raises an
    EmptyPipelineException when it handles an incoming request. It's primary
    purpose is for use in the MiddlewarePipe as a fallback handler during
    handle() operations.

Changed

  • #178 provides some performance improvements to MiddlewarePipe::handle() by
    having it create an instance of EmptyPipelineHandler to use as a fallback
    handler when it calls process() on itself. This prevents cloning of the
    pipeline in this scenario, which is used when it acts as an application
    entrypoint.

  • #185 removes the "final" declaration from the ErrorHandler class, to allow
    more easily mocking it for testing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

zend-stratigility 3.0.3

06 Feb 17:36
Compare
Choose a tag to compare

Added

  • #184 adds support for PHP 7.3.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

zend-stratigility 3.0.2

24 Jul 20:40
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • #177 removes a conditional from Zend\Stratigility\Middleware\ErrorHandler that can
    never be reached.

Fixed

  • Nothing.

zend-stratigility 2.2.2

16 Apr 18:22
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • #169 fixes an issue with how the PathMiddlewareDecorator attempts to truncate the path
    when the path is matched case insensitively. Previously, an exception was incorrectly raised;
    now it identifies and truncates correctly.

zend-stratigility 3.0.1

04 Apr 17:48
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • #165 fixes an
    issue with the PathMiddlewareDecorator whereby it was using the original
    request when invoking the handler it creates, instead of prepending the
    configured path prefix to the request URI created. With the fix, if middleware
    alters the request path passed to the handler, the changes will now propagate
    to later middleware. As an example:

    new PathMiddlewareDecorator('/api', middleware(function ($request, $handler) {
        $uri = $request->getUri();
        if (! preg_match('#^/v\d+/#', $uri->getPath())) {
            $request = $request->withUri($uri->withPath('/v1' . $uri->getPath()));
        }
        return $handler->handle($request);
    }));

    For the request path /api/books, the above will now correctly result in
    /api/v1/books being propagated to lower layers of the application, instead
    of /api/books.

zend-stratigility 2.2.1

04 Apr 17:45
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • #167 fixes an
    issue with the PathMiddlewareDecorator whereby it was using the original
    request when invoking the handler it creates, instead of prepending the
    configured path prefix to the request URI created. With the fix, if middleware
    alters the request path passed to the handler, the changes will now propagate
    to later middleware. As an example:

    new PathMiddlewareDecorator('/api', middleware(function ($request, $handler) {
        $uri = $request->getUri();
        if (! preg_match('#^/v\d+/#', $uri->getPath())) {
            $request = $request->withUri($uri->withPath('/v1' . $uri->getPath()));
        }
        return $handler->handle($request);
    }));

    For the request path /api/books, the above will now correctly result in
    /api/v1/books being propagated to lower layers of the application, instead of
    /api/books.

zend-stratigility 3.0.0

15 Mar 14:13
Compare
Choose a tag to compare

Added

  • #146 adds a new interface, Zend\Stratigility\MiddlewarePipeInterface. It extends the PSR-15 MiddlewareInterface and RequestHandlerInterface, and defines one additional method, pipe(MiddlewareInterface $middleware) : void.

  • #150 adds a new class, Zend\Stratigility\Middleware\RequestHandlerMiddleware. The class implements the PSR-15 RequestHandlerInterface and MiddlewareInterface, and accepts a single constructor argument, a RequestHandlerInterface instance. Each of its handle() and process() methods proxy to the composed request handler's handle() method, returning its result.

    This class can be useful for adapting request handlers to use within pipelines.

  • #142 adds a new class, Zend\Stratigility\Middleware\HostMiddlewareDecorator, which provides host segregation functionality for middleware, allowing conditional execution of middleware only if the requested host matches a configured host.

    // Only process $middleware if the request host matches 'example.com':
    $pipeline->pipe(new HostMiddlewareDecorator('example.com', $middleware));

    Additionally, the patch provides a utility function, Zend\Stratigility\host(), to simplify the above declaration:

    $pipeline->pipe(host('example.com', $middleware));
  • #128 adds a marker interface, Zend\Stratigility\Exception\ExceptionInterface; all package exceptions now implement this interface, allowing you to catch all package-related exceptions by typehinting against it.

Changed

  • #145 updates the component to implement and consume ONLY PSR-15 interfaces; http-interop interfaces and callable middleware are no longer directly supported (though Stratigility provides decorators for the latter in order to cast them to PSR-15 implementations).

  • #134 and #146 modify MiddlewarePipe in two ways: it now implements the new MiddlewarePipeInterface, and is marked as final, disallowing direct extension. Either decorate an instance in a custom MiddlewarePipeInterface implementation, or create a custom PSR-15 MiddlewareInterface implementation if piping is not necessary or will allow additional types.

  • #155 modifies each of the following classes to mark them final:

    • Zend\Stratigility\Middleware\CallableMiddlewareDecorator
    • Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator
    • Zend\Stratigility\Middleware\HostMiddlewareDecorator
    • Zend\Stratigility\Middleware\NotFoundHandler
    • Zend\Stratigility\Middleware\OriginalMessages
    • Zend\Stratigility\Middleware\PathMiddlewareDecorator
    • Zend\Stratigility\Middleware\RequestHandlerMiddleware
    • Zend\Stratigility\Next
  • #134, #145, and #146 update MiddlewarePipe to implement Psr\Http\Server\RequestHandlerInterface. Calling it will cause it to pull the first middleware off the queue and create a Next implementation that uses the remaining queue as the request handler; it then processes the middleware.

  • #134 removes the ability to specify a path when calling pipe(); use the PathMiddlewareDecorator or path() utility function to pipe middleware with path segregation.

  • #153 modifies the first argument of the Zend\Expressive\Middleware\ErrorHandler and NotFoundHandler classes. Previously, they each expected a Psr\Http\Message\ResponseInterface instance; they now both expect a PHP callable capable of producing such an instance. This change was done to simplify re-use of a service for producing unique response instances within dependency injection containers.

  • #157 marks the package as conflicting with zendframework/zend-diactoros versions less than 1.7.1. This is due to the fact that that version provides a bugfix for its Uri::getHost() implementation that ensures it follows the PSR-7 and IETF RFC 3986 specifications.

Deprecated

  • Nothing.

Removed

  • #163 removes Zend\Stratigility\Middleware\PathRequestHandlerDecorator, as it was deprecated in 2.2, and no longer used with the 3.0 code base.

  • #122 removes support for PHP versions 5.6, 7.0, as well as HHVM.

  • #122 removes the following classes:

    • Zend\Stratigility\Delegate\CallableDelegateDecorator
    • Zend\Stratigility\Exception\InvalidRequestTypeException
    • Zend\Stratigility\Exception\MissingResponsePrototypeException
    • Zend\Stratigility\MiddlewareInterface
    • Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper
    • Zend\Stratigility\Middleware\CallableMiddlewareWrapper
    • Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory
    • Zend\Stratigility\NoopFinalHandler
  • #134 removes the class Zend\Stratigility\Route. This was an internal message passed between a MiddlewarePipe and Next instance, and its removal should not affect end users.

  • #134 removes Zend\Stratigility\Exception\InvalidMiddlewareException, as the exception is no longer raised by MiddlewarePipe.

Fixed

  • Nothing.

zend-stratigility 2.2.0

12 Mar 21:13
Compare
Choose a tag to compare

Added

  • #140 adds the class Zend\Stratigility\Middleware\CallableMiddlewareDecorator for the purpose of decorating callable, standards-signature middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware as the sole argument, or use the Zend\Stratigility\middleware() utility function to generate the instance: middleware($callable).

  • #140 adds the class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator for the purpose of decorating callable, double-pass middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware and a response instance as arguments, or use the Zend\Stratigility\doublePassMiddleware() utility function to generate the instance: doublePassMiddleware($callable, $response).

  • #140 adds the class Zend\Stratigility\Middleware\PathMiddlewareDecorator for the purposes of creating path-segregated middleware. The constructor expects a string path literal as the first argument, and an Interop\Http\Server\MiddlewareInterface instance for the second argument. Alternately, use the Zend\Stratigility\path() utility function to generate the instance: path('/foo', $middleware).

    This decorator class replaces usage of the $path argument to MiddlewarePipe::pipe(), and should be used to ensure your application is forwards-compatible with the upcoming version 3 release.

Changed

  • Nothing.

Deprecated

  • #140 deprecates the class Zend\Stratigility\Route. This class is an internal detail, and will be removed in version 3.0.0.

  • #140 deprecates the class Zend\Stratigility\Exception\InvalidMiddlewareException. This class will be removed in version 3.0.0 as it will no longer be necessary due to typehint usage.

  • #140 deprecates the class Zend\Stratigility\Exception\InvalidRequestTypeException as it is no longer used by the package. It will be removed in version 3.0.0.

  • #140 deprecates the class Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\CallableMiddlewareDecorator, or the utility function middleware(), to decorate callable standards-signature middleware.

  • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator, or the utility function doublePassMiddleware(), to decorate callable double pass middleware.

  • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory as the class it is associated will be removed starting in version 3.0.0. The class will be removed in version 3.0.0.

  • #140 deprecates the class Zend\Stratigility\NoopFinalHandler as the class will be removed starting in version 3.0.0.

  • #140 deprecates the two-argument form of Zend\Stratigility\MiddlewarePipe::pipe(). If you need to perform path segregation, use the Zend\Stratigility\Middleware\PathMiddlewareDecorator class and/or the Zend\Stratigility\path() function to decorate your middleware in order to provide path segregation.

  • #140 deprecates the piping of double pass middleware directly to pipe(); decorate your double-pass middleware using Zend\Stratigility\Middleware\DoublePassMiddleware or Zend\Stratigility\doublePassMiddleware() prior to piping.

  • #159 deprecates Zend\Stratigility\MiddlewarePipe::setCallableMiddlewareDecorator(). Use Zend\Stratigility\doublePassMiddleware() or Zend\Stratigility\Middleware\DoublePassMiddleware prior to passing your double-pass middleware to MiddlewarePipe::pipe().

  • #159 deprecates Zend\Stratigility\MiddlewarePipe::setResponsePrototype(). This was used only to seed an instance of Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory previously; pass your response prototype directly to a new instance of Zend\Stratigility\Middleware\DoublePassMiddleware or the ``Zend\Stratigility\doublePassMiddleware()` function instead.

  • #159 deprecates Zend\Stratigility\MiddlewarePipe::hasResponsePrototype().

Removed

  • Nothing.

Fixed

  • Nothing.

zend-stratigility 2.2.0rc3

08 Mar 20:48
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Fixes the signature of PathRequestHandlerDecorator::process() to typehint against the PSR-7 ServerRequestInterface, and not RequestInterface.