From 4f58887f82724088f2c2b04574d60443c907d0bb Mon Sep 17 00:00:00 2001 From: Zike Date: Fri, 10 Nov 2023 11:35:53 -0500 Subject: [PATCH] Update Request.zep The Http request service cannot invoke filterService from container. --- phalcon/Http/Request.zep | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/phalcon/Http/Request.zep b/phalcon/Http/Request.zep index be9ed7e50b..9e529c36f1 100644 --- a/phalcon/Http/Request.zep +++ b/phalcon/Http/Request.zep @@ -17,6 +17,7 @@ use Phalcon\Filter\FilterInterface; use Phalcon\Http\Message\RequestMethodInterface; use Phalcon\Http\Request\File; use Phalcon\Http\Request\FileInterface; +use Phalcon\Filter\FilterFactory; use Phalcon\Http\Request\Exception; use Phalcon\Support\Helper\Json\Decode; use UnexpectedValueException; @@ -1646,15 +1647,13 @@ class Request extends AbstractInjectionAware implements RequestInterface, Reques if typeof filterService != "object" { let container = this->container; - - if container === null { - throw new Exception( - "A dependency injection container is required to access the 'filter' service" - ); + if typeof container == "object" && container->has("filter") { + let filter = container->getShared("filter"), + this->filterService = filter; + } else { + this->filterService = (new FilterFactory())->newInstance(); } - - let filterService = container->getShared("filter"), - this->filterService = filterService; + this->filterService = filterService; } return this->filterService;