Skip to content

Commit

Permalink
changed the way we store the current ob level (refs #2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 11, 2011
1 parent fb0fffe commit bb5fb79
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/HttpKernel.php
Expand Up @@ -40,6 +40,8 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
$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) {
Expand Down
Expand Up @@ -65,7 +65,7 @@ protected function getAndCleanOutputBuffering()
// 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();
Expand Down
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpFoundation\Request;

class ExceptionControllerTest extends TestCase
{
Expand Down Expand Up @@ -48,6 +49,7 @@ protected function setUp()
->expects($this->any())
->method('renderResponse')
->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Response')));
$this->request = Request::create('/');
$this->container = $this->getContainer();
}

Expand All @@ -64,12 +66,7 @@ protected function tearDown()

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);
Expand All @@ -79,7 +76,7 @@ private function getContainer()
{
$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__);
Expand Down
13 changes: 0 additions & 13 deletions src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -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';
Expand Down Expand Up @@ -121,8 +120,6 @@ public function boot()
return;
}

$this->startObLevel = ob_get_level();

// init bundles
$this->initializeBundles();

Expand Down Expand Up @@ -424,16 +421,6 @@ public function getStartTime()
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.
*
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Component/HttpKernel/KernelInterface.php
Expand Up @@ -179,13 +179,6 @@ function getContainer();
*/
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.
*
Expand Down

0 comments on commit bb5fb79

Please sign in to comment.