Skip to content

Commit

Permalink
Don't run filters when using spark. Closes #1519
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Nov 23, 2018
1 parent 90f6f37 commit 2047b5a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions spark
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* this class mainly acts as a passthru to the framework itself.
*/

define('SPARKED', true);

/*
*---------------------------------------------------------------
* BOOTSTRAP THE APPLICATION
Expand Down
34 changes: 23 additions & 11 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,19 @@ protected function handleRequest(RouteCollectionInterface $routes = null, $cache

$uri = $this->request instanceof CLIRequest ? $this->request->getPath() : $this->request->uri->getPath();

$possibleRedirect = $filters->run($uri, 'before');
if ($possibleRedirect instanceof RedirectResponse)
// Never run filters when running through Spark cli
if (! defined('SPARKED'))
{
return $possibleRedirect;
}
// 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();
$possibleRedirect = $filters->run($uri, 'before');
if ($possibleRedirect instanceof RedirectResponse)
{
return $possibleRedirect;
}
// 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();
Expand All @@ -331,9 +335,17 @@ protected function handleRequest(RouteCollectionInterface $routes = null, $cache
// so it can be used with the output.
$this->gatherOutput($cacheConfig, $returned);

$filters->setResponse($this->response);
// Run "after" filters
$response = $filters->run($uri, 'after');
// Never run filters when running through Spark cli
if (! defined('SPARKED'))
{
$filters->setResponse($this->response);
// Run "after" filters
$response = $filters->run($uri, 'after');
}
else
{
$response = $this->response;
}

if ($response instanceof Response)
{
Expand Down

0 comments on commit 2047b5a

Please sign in to comment.