-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
ErrorException: Notice: ob_end_clean(): failed to delete buffer. #390
Comments
Are you (or Symfony 2) using Output Buffering in some way? |
The PhpEngine and Twig use output buffering. |
Yes, symfony and twig are using Output Buffering I don't know how symfony generates the 404 page from the NotFoundException. |
I think the problem is in the ExceptionController from the TwigBundle.
|
Fabien told me that he is investigating the issue. There may be a new Twig / Symfony 2 release soon to address it. |
A quick workaround: in TestCase.php: |
After upgrading I could not successfully revert to 3.5.15. After a bit of trial and error, figured out the exact versions that works:
Edit: s/5.3.15/3.5.15/ |
Thank you very much |
Symfony 2.0.5 did not solve this |
We too have experienced hundreds of these "ob_end_clean(): failed to delete buffer" messages since moving from PHPUnit 3.5.15 to 3.6.0. We use the Zend Framework (v1.11.11) -- anybody else experiencing this? We have guarded our own few uses of ob_end_clean() like @tarjei mentions. Using process isolation helps, but not completely (and the "RuntimeException" errors reported when using process isolation don't exactly help either). Curious to know how pervasive this, and what, if anything, can be done about it (apart from staying on PHPUnit 3.5.15). |
I'm having the same issue. Reverting to 3.5.15 was a pain so I'm using the workaround for now. |
So the problem seems to be that code outside of PHPUnit stops the output buffering that was started by PHPUnit. There is nothing I can do about that in PHPUnit. |
This error is solved? i don't understand this: A quick workaround: in TestCase.php: Cheers! |
ok, if the buffer is empty this file in the line 833, will broken /usr/share/pear/PHPUnit/Framework/TestCase.php then we need put this lines and check before remove it if (ob_get_length() > 0 ) { with this, works for me Cheers! |
I will not make a workaround in PHPUnit for an issue that is not a PHPUnit issue. |
I can understand your point of view when saying you will not patch an issue that is not a PHPUnit issue. But still, using a buffered output without checking if the buffer really exists and needs to be cleaned can be an issue in other cases. Plus, the issue has been confirmed using Zend/Symfony2. Two of the most used php frameworks. It might be a small concession for better integration with those frameworks. Anyway, as long as this issue will be "open" as "not resolved", I'll use the patched version locally. |
This is an issue in Zend Framework and Symfony. Why should that issue be worked around in PHPUnit? |
My earlier stated problem looks like it has nothing to do with Zend Framework, but is in fact a problem within our codebase, where we have a few unbalanced |
Issue in symfony tracker (for those looking for it): symfony/symfony#2531 |
And for those wondering, the issue in symfony has now been fixed: symfony/symfony#2617. |
thanks @justjkk ! your solution did the trick for me |
are you saying that i cannot have ob_start within my code? |
FYI (not a problem of Phpunit): you could get this error if you use newrelic: <?php
ob_start();
var_dump(ob_get_level());
//1
newrelic_set_appname('foo')
var_dump(ob_get_level());
//0 |
Commits ------- 29e12af [TwigBundle] Extract output buffer cleaning to method ed1a6c2 [TwigBundle] Do not clean output buffering below initial level Discussion ---------- [TwigBundle] Do not clean output buffering below initial level This resulted in issues with PHPUnit 3.6, which will buffer all output and clean them in the end. Since we cleaned their buffer, the subsequent clean would raise a warning. This is documented in [issue 390](sebastianbergmann/phpunit#390) of the PHPUnit tracker. Closes #2531. This also affects FOSRestBundle's ExceptionController /cc @lsmith. --------------------------------------------------------------------------- by fabpot at 2011/11/11 07:33:24 -0800 I have a similar fix locally but I have not merged it yet as it looks a bit dirty (but I've not a better idea yet). Anyway, your PR is better than mine as you've added some unit tests already.
Hi I have tried test my laravel app by using phpunit. Phpunit returns this error: " phpunit --colors app/tests/ Time: 431 ms, Memory: 14.75Mb There was 1 error:
FAILURES! My Test file:
}" This line is causing the error: If I change this line such as: This line works on no errors If the path that requests has'nt need to login, Phpunit test works with no errors.. Such as: public function testindex() {
} Ubuntu 14.04 is getting with PHPUnit 3.7.28 and This version includes this bug. |
For what it's worth I fixed it in my case. Laravel 4.2, PHPUnit 3.7.28 Issue: One of my blade view files had an extra useless @Stop at the end. PS: Like sebastianbergmann said, it's something the framework is doing that's causing that error. |
Hello!
I'am using symfony 2.0.4 and the example was working with phpunit 3.5.15.
Since the upgrade to phpunit 3.6 i get the following output:
phpunit -c app
!/usr/local/Cellar/php/5.3.6/bin/php
PHPUnit 3.6.0 by Sebastian Bergmann.
Configuration read from /Users/sebiprivat/Downloads/Symfony/app/phpunit.xml.dist
.E
Time: 1 second, Memory: 25.50Mb
There was 1 error:
ErrorException: Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in /usr/local/Cellar/php/5.3.6/lib/php/PHPUnit/Framework/TestCase.php line 833
/Users/sebiprivat/Downloads/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php:65
/usr/local/Cellar/php/5.3.6/bin/phpunit:46
FAILURES!
Tests: 2, Assertions: 2, Errors: 1.
MacPro:Symfony sebiprivat$
Steps to reproduce the error:
http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.4.tgz
There should be one test in the Acme Demo Bundle
I edited in src/Acme/DemoBundle/Controller/DemoController.php to
public function helloAction($name)
{
if (!$name) {
throw new NotFoundHttpException("No Name!");
}
return array('name' => $name);
}
and added a new test in src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
public function testInvalidName()
{
$client = $this->createClient();
$crawler = $client->request('GET', '/demo/hello/');
$this->assertTrue($client->getResponse()->isNotFound());
}
Now running phpunit -c app will get the following output:
phpunit -c app
!/usr/local/Cellar/php/5.3.6/bin/php
PHPUnit 3.6.0 by Sebastian Bergmann.
Configuration read from /Users/sebiprivat/Downloads/Symfony/app/phpunit.xml.dist
.E
Time: 1 second, Memory: 25.50Mb
There was 1 error:
ErrorException: Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in /usr/local/Cellar/php/5.3.6/lib/php/PHPUnit/Framework/TestCase.php line 833
/Users/sebiprivat/Downloads/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php:65
/usr/local/Cellar/php/5.3.6/bin/phpunit:46
FAILURES!
Tests: 2, Assertions: 2, Errors: 1.
MacPro:Symfony sebiprivat$
The text was updated successfully, but these errors were encountered: