diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 412fa7447d..bff25324a3 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -37,6 +37,7 @@ */ use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\Request; +use CodeIgniter\HTTP\ResponseInterface; use Config\Services; use Config\Cache; use CodeIgniter\HTTP\URI; @@ -202,7 +203,17 @@ class CodeIgniter // Check for a cached page. Execution will stop // if the page has been cached. $cacheConfig = new Cache(); - $this->displayCache($cacheConfig); + $response = $this->displayCache($cacheConfig); + if ($response instanceof ResponseInterface) + { + if ($returnResponse) + { + return $response; + } + + $this->response->send(); + $this->callExit(EXIT_SUCCESS); + } try { @@ -232,6 +243,7 @@ class CodeIgniter * @param $cacheConfig * @param bool $returnResponse * + * @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed * @throws \CodeIgniter\Filters\Exceptions\FilterException */ protected function handleRequest(RouteCollectionInterface $routes = null, $cacheConfig, bool $returnResponse = false) @@ -495,8 +507,9 @@ class CodeIgniter } $output = $this->displayPerformanceMetrics($output); - $this->response->setBody($output)->send(); - $this->callExit(EXIT_SUCCESS); + $this->response->setBody($output); + + return $this->response; }; } diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index fcdc9baf27..88c39bf57c 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -79,7 +79,7 @@ class RedisHandlerTest extends \CIUnitTestCase public function testDestruct() { - $this->redisHandler = new RedisHandler($this->config->redis); + $this->redisHandler = new RedisHandler($this->config); $this->redisHandler->initialize(); $this->assertInstanceOf(RedisHandler::class, $this->redisHandler);