Skip to content

Commit

Permalink
No need to use mb functions here
Browse files Browse the repository at this point in the history
When mb functions are used and a large response is given the OOM happens as mb functions will use large quantities of memory.
  • Loading branch information
Miha Vrhovnik authored and fabpot committed Apr 18, 2014
1 parent 5b72e5a commit 4e8ba13
Showing 1 changed file with 2 additions and 10 deletions.
Expand Up @@ -96,16 +96,8 @@ public function onKernelResponse(FilterResponseEvent $event)
*/
protected function injectToolbar(Response $response)
{
if (function_exists('mb_stripos')) {
$posrFunction = 'mb_strripos';
$substrFunction = 'mb_substr';
} else {
$posrFunction = 'strripos';
$substrFunction = 'substr';
}

$content = $response->getContent();
$pos = $posrFunction($content, '</body>');
$pos = strripos($content, '</body>');

if (false !== $pos) {
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
Expand All @@ -115,7 +107,7 @@ protected function injectToolbar(Response $response)
'token' => $response->headers->get('X-Debug-Token'),
)
))."\n";
$content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
$content = substr($content, 0, $pos).$toolbar.substr($content, $pos);
$response->setContent($content);
}
}
Expand Down

0 comments on commit 4e8ba13

Please sign in to comment.