changed the way we store the current ob level (refs #2617)

This commit is contained in:
Fabien Potencier 2011-11-11 23:35:49 +01:00
parent fb0fffe6db
commit bb5fb79c3d
5 changed files with 7 additions and 28 deletions

View File

@ -40,6 +40,8 @@ class HttpKernel extends BaseHttpKernel
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
$request->headers->set('X-Php-Ob-Level', ob_get_level());
try {
$response = parent::handle($request, $type, $catch);
} catch (\Exception $e) {

View File

@ -65,7 +65,7 @@ class ExceptionController extends ContainerAware
// some Windows configurations where ob_get_level()
// never reaches 0
$count = 100;
$startObLevel = $this->container->get('kernel')->getStartObLevel();
$startObLevel = $this->container->get('request')->headers->get('X-Php-Ob-Level', -1);
$currentContent = '';
while (ob_get_level() > $startObLevel && --$count) {
$currentContent .= ob_get_clean();

View File

@ -17,6 +17,7 @@ use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpFoundation\Request;
class ExceptionControllerTest extends TestCase
{
@ -48,6 +49,7 @@ class ExceptionControllerTest extends TestCase
->expects($this->any())
->method('renderResponse')
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
$this->request = Request::create('/');
$this->container = $this->getContainer();
}
@ -64,12 +66,7 @@ class ExceptionControllerTest extends TestCase
public function testOnlyClearOwnOutputBuffers()
{
$this->container->enterScope('request');
$this->kernel
->expects($this->once())
->method('getStartObLevel')
->will($this->returnValue(1));
$this->request->headers->set('X-Php-Ob-Level', 1);
$this->controller->setContainer($this->container);
$this->controller->showAction($this->flatten);
@ -79,7 +76,7 @@ class ExceptionControllerTest extends TestCase
{
$container = new ContainerBuilder();
$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->setParameter('kernel.bundles', array());
$container->setParameter('kernel.cache_dir', __DIR__);

View File

@ -55,7 +55,6 @@ abstract class Kernel implements KernelInterface
protected $booted;
protected $name;
protected $startTime;
protected $startObLevel;
protected $classes;
const VERSION = '2.0.6-DEV';
@ -121,8 +120,6 @@ abstract class Kernel implements KernelInterface
return;
}
$this->startObLevel = ob_get_level();
// init bundles
$this->initializeBundles();
@ -424,16 +421,6 @@ abstract class Kernel implements KernelInterface
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.
*

View File

@ -179,13 +179,6 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
*/
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.
*