8000 [Debug] Remove deprecated ExceptionHandler::createResponse by nicolas-grekas · Pull Request #15422 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Debug] Remove deprecated ExceptionHandler::createResponse #15422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2015
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
52 changes: 2 additions & 50 deletions src/Symfony/Component/Debug/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setFileLinkFormat($format)
public function handle(\Exception $exception)
{
if (null === $this->handler || $exception instanceof OutOfMemoryException) {
$this->failSafeHandle($exception);
$this->sendPhpResponse($exception);

return;
}
Expand All @@ -128,8 +128,7 @@ public function handle(\Exception $exception)
return '';
});


$this->failSafeHandle($exception);
$this->sendPhpResponse($exception);
while (null === $this->caughtBuffer && ob_end_flush()) {
// Empty loop, everything is in the condition
}
Expand Down Expand Up @@ -162,33 +161,6 @@ public function handle(\Exception $exception)
}
}

/**
* Sends a response for the given Exception.
*
* If you have the Symfony HttpFoundation component installed,
* this method will use it to create and send the response. If not,
* it will fallback to plain PHP functions.
*
* @param \Exception $exception An \Exception instance
*/
private function failSafeHandle(\Exception $exception)
{
if (class_exists('Symfony\Component\HttpFoundation\Response', false)
&& __CLASS__ !== get_class($this)
&& ($reflector = new \ReflectionMethod($this, 'createResponse'))
&& __CLASS__ !== $reflector->class
) {
$response = $this->createResponse($exception);
$response->sendHeaders();
$response->sendContent();
@trigger_error(sprintf("The %s::createResponse method is deprecated since 2.8 and won't be called anymore when handling an exception in 3.0.", $reflector->class), E_USER_DEPRECATED);

return;
}

$this->sendPhpResponse($exception);
}

/**
* Sends the error associated with the given Exception as a plain PHP response.
*
Expand All @@ -214,26 +186,6 @@ public function sendPhpResponse($exception)
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
}

/**
* Creates the error Response associated with the given Exception.
*
* @param \Exception|FlattenException $exception An \Exception instance
*
* @return Response A Response instance
*
* @deprecated since 2.8, to be removed in 3.0.
*/
public function createResponse($exception)
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);

if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}

return Response::create($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
}

/**
* Gets the HTML content associated with the given exception.
*
Expand Down
0