Don't run filters when using spark. Closes #1519

This commit is contained in:
Lonnie Ezell 2018-11-22 22:49:08 -06:00
parent 90f6f37111
commit 2047b5a1f5
No known key found for this signature in database
GPG Key ID: 71836D6EF250F1D1
2 changed files with 25 additions and 11 deletions

2
spark
View File

@ -12,6 +12,8 @@
* this class mainly acts as a passthru to the framework itself. * this class mainly acts as a passthru to the framework itself.
*/ */
define('SPARKED', true);
/* /*
*--------------------------------------------------------------- *---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION * BOOTSTRAP THE APPLICATION

View File

@ -297,15 +297,19 @@ class CodeIgniter
$uri = $this->request instanceof CLIRequest ? $this->request->getPath() : $this->request->uri->getPath(); $uri = $this->request instanceof CLIRequest ? $this->request->getPath() : $this->request->uri->getPath();
$possibleRedirect = $filters->run($uri, 'before'); // Never run filters when running through Spark cli
if ($possibleRedirect instanceof RedirectResponse) if (! defined('SPARKED'))
{ {
return $possibleRedirect; $possibleRedirect = $filters->run($uri, 'before');
} if ($possibleRedirect instanceof RedirectResponse)
// If a Response instance is returned, the Response will be sent back to the client and script execution will stop {
if ($possibleRedirect instanceof ResponseInterface) return $possibleRedirect;
{ }
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)
{
return $possibleRedirect->send();
}
} }
$returned = $this->startController(); $returned = $this->startController();
@ -331,9 +335,17 @@ class CodeIgniter
// so it can be used with the output. // so it can be used with the output.
$this->gatherOutput($cacheConfig, $returned); $this->gatherOutput($cacheConfig, $returned);
$filters->setResponse($this->response); // Never run filters when running through Spark cli
// Run "after" filters if (! defined('SPARKED'))
$response = $filters->run($uri, 'after'); {
$filters->setResponse($this->response);
// Run "after" filters
$response = $filters->run($uri, 'after');
}
else
{
$response = $this->response;
}
if ($response instanceof Response) if ($response instanceof Response)
{ {