changed the way we store the current ob level (refs #2617)
This commit is contained in:
parent
fb0fffe6db
commit
bb5fb79c3d
@ -40,6 +40,8 @@ class HttpKernel extends BaseHttpKernel
|
|||||||
$this->container->enterScope('request');
|
$this->container->enterScope('request');
|
||||||
$this->container->set('request', $request, 'request');
|
$this->container->set('request', $request, 'request');
|
||||||
|
|
||||||
|
$request->headers->set('X-Php-Ob-Level', ob_get_level());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = parent::handle($request, $type, $catch);
|
$response = parent::handle($request, $type, $catch);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -65,7 +65,7 @@ class ExceptionController extends ContainerAware
|
|||||||
// some Windows configurations where ob_get_level()
|
// some Windows configurations where ob_get_level()
|
||||||
// never reaches 0
|
// never reaches 0
|
||||||
$count = 100;
|
$count = 100;
|
||||||
$startObLevel = $this->container->get('kernel')->getStartObLevel();
|
$startObLevel = $this->container->get('request')->headers->get('X-Php-Ob-Level', -1);
|
||||||
$currentContent = '';
|
$currentContent = '';
|
||||||
while (ob_get_level() > $startObLevel && --$count) {
|
while (ob_get_level() > $startObLevel && --$count) {
|
||||||
$currentContent .= ob_get_clean();
|
$currentContent .= ob_get_clean();
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Scope;
|
use Symfony\Component\DependencyInjection\Scope;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class ExceptionControllerTest extends TestCase
|
class ExceptionControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@ class ExceptionControllerTest extends TestCase
|
|||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('renderResponse')
|
->method('renderResponse')
|
||||||
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
|
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
|
||||||
|
$this->request = Request::create('/');
|
||||||
$this->container = $this->getContainer();
|
$this->container = $this->getContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +66,7 @@ class ExceptionControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testOnlyClearOwnOutputBuffers()
|
public function testOnlyClearOwnOutputBuffers()
|
||||||
{
|
{
|
||||||
$this->container->enterScope('request');
|
$this->request->headers->set('X-Php-Ob-Level', 1);
|
||||||
|
|
||||||
$this->kernel
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getStartObLevel')
|
|
||||||
->will($this->returnValue(1));
|
|
||||||
|
|
||||||
$this->controller->setContainer($this->container);
|
$this->controller->setContainer($this->container);
|
||||||
$this->controller->showAction($this->flatten);
|
$this->controller->showAction($this->flatten);
|
||||||
@ -79,7 +76,7 @@ class ExceptionControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->addScope(new Scope('request'));
|
$container->addScope(new Scope('request'));
|
||||||
$container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
|
$container->set('request', $this->request);
|
||||||
$container->set('templating', $this->templating);
|
$container->set('templating', $this->templating);
|
||||||
$container->setParameter('kernel.bundles', array());
|
$container->setParameter('kernel.bundles', array());
|
||||||
$container->setParameter('kernel.cache_dir', __DIR__);
|
$container->setParameter('kernel.cache_dir', __DIR__);
|
||||||
|
@ -55,7 +55,6 @@ abstract class Kernel implements KernelInterface
|
|||||||
protected $booted;
|
protected $booted;
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $startTime;
|
protected $startTime;
|
||||||
protected $startObLevel;
|
|
||||||
protected $classes;
|
protected $classes;
|
||||||
|
|
||||||
const VERSION = '2.0.6-DEV';
|
const VERSION = '2.0.6-DEV';
|
||||||
@ -121,8 +120,6 @@ abstract class Kernel implements KernelInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->startObLevel = ob_get_level();
|
|
||||||
|
|
||||||
// init bundles
|
// init bundles
|
||||||
$this->initializeBundles();
|
$this->initializeBundles();
|
||||||
|
|
||||||
@ -424,16 +421,6 @@ abstract class Kernel implements KernelInterface
|
|||||||
return $this->debug ? $this->startTime : -INF;
|
return $this->debug ? $this->startTime : -INF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ob_level at the start of the request
|
|
||||||
*
|
|
||||||
* @return integer The request start ob_level
|
|
||||||
*/
|
|
||||||
public function getStartObLevel()
|
|
||||||
{
|
|
||||||
return $this->startObLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cache directory.
|
* Gets the cache directory.
|
||||||
*
|
*
|
||||||
|
@ -179,13 +179,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
|||||||
*/
|
*/
|
||||||
function getStartTime();
|
function getStartTime();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ob_level at the start of the request
|
|
||||||
*
|
|
||||||
* @return integer The request start ob_level
|
|
||||||
*/
|
|
||||||
function getStartObLevel();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cache directory.
|
* Gets the cache directory.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user