bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

error: ob_end_flush() failed to delete buffer zlib output compression - hard 500 error #262

Closed MINORITYmaN closed 11 years ago

MINORITYmaN commented 11 years ago

just for your information referencing to this post http://www.php.net/manual/pl/function.ob-end-clean.php#103817

Take note that if you change zlib output compression setting in
between ob_start and ob_end_clean or ob_end_flush, 
you will get an error:
ob_end_flush() failed to delete buffer zlib output compression

so i made just a small modification (without using htaccess solution) ang changed line: https://github.com/bcosca/fatfree/blob/dev/lib/base.php#L860 to

$ob_get_status = ob_get_status();
if($ob_get_status['name']!='zlib output compression')ob_clean();

cuz having no routing defined in the dev and stable version caused at my hoster an hard 500 error with no output.

php error log

[Mon Feb 11 14:37:05 2013] [error] - /home/users/f3/lib/base.php:1396
[Mon Feb 11 14:37:05 2013] [error] PHP Fatal error:  Uncaught exception 'ErrorException' with message 'ob_clean()
[<a href='ref.outcontrol'>ref.outcontrol</a>]: failed to delete buffer zlib output compression' in
/home/users/f3/lib/base.php:1396\nStack trace:\n
#0 [internal function]: {closure}(8, 'ob_clean() [<a ...', '/home/users/f3...', 860, Array)\n
#1 /home/users/f3/lib/base.php(860): ob_clean()\n
#2 /home/users/f3/lib/base.php(1357): Base->error(500, 'Fatal error: Un...', Array)\n
#3 [internal function]: Base->unload()\n
#4 {main}\n  thrown in /home/users/f3/lib/base.php on line 1396
bcosca commented 11 years ago

Fixed.

if (!count(array_diff(ob_list_handlers(),array('default output handler'))))
    ob_clean();

See latest commit.

MINORITYmaN commented 11 years ago

(: had the same idea