Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Request;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\HTTP\URI;
use CodeIgniter\Router\Exceptions\RedirectException;
Expand Down Expand Up @@ -297,7 +296,7 @@ protected function initializeKint()
* @param RouteCollectionInterface|null $routes
* @param boolean $returnResponse
*
* @return boolean|RequestInterface|Response|ResponseInterface|mixed
* @return boolean|RequestInterface|ResponseInterface|mixed
* @throws RedirectException
* @throws Exception
*/
Expand Down Expand Up @@ -378,7 +377,7 @@ public function useSafeOutput(bool $safe = true)
* @param Cache $cacheConfig
* @param boolean $returnResponse
*
* @return RequestInterface|\CodeIgniter\HTTP\Response|ResponseInterface|mixed
* @return RequestInterface|ResponseInterface|mixed
* @throws RedirectException
*/
protected function handleRequest(RouteCollectionInterface $routes = null, Cache $cacheConfig, bool $returnResponse = false)
Expand All @@ -401,15 +400,12 @@ protected function handleRequest(RouteCollectionInterface $routes = null, Cache
// Never run filters when running through Spark cli
if (! defined('SPARKED'))
{
$possibleRedirect = $filters->run($uri, 'before');
if ($possibleRedirect instanceof RedirectResponse)
{
return $possibleRedirect->send();
}
// If a Response instance is returned, the Response will be sent back to the client and script execution will stop
if ($possibleRedirect instanceof ResponseInterface)
$possibleResponse = $filters->run($uri, 'before');

// If a ResponseInterface instance is returned then send it back to the client and stop
if ($possibleResponse instanceof ResponseInterface)
{
return $possibleRedirect->send();
return $returnResponse ? $possibleResponse : $possibleResponse->pretend($this->useSafeOutput)->send();
}
}

Expand Down Expand Up @@ -454,7 +450,7 @@ protected function handleRequest(RouteCollectionInterface $routes = null, Cache
}
}

if ($response instanceof Response)
if ($response instanceof ResponseInterface)
{
$this->response = $response;
}
Expand Down Expand Up @@ -1038,7 +1034,7 @@ protected function gatherOutput(Cache $cacheConfig = null, $returned = null)
// echoed already.
// We also need to save the instance locally
// so that any status code changes, etc, take place.
if ($returned instanceof Response)
if ($returned instanceof ResponseInterface)
{
$this->response = $returned;
$returned = $returned->getBody();
Expand Down