|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-12-18 14:15 UTC] jani@php.net
[2009-02-13 11:50 UTC] davidc@php.net
[2012-01-17 12:46 UTC] mike@php.net
[2012-01-17 12:46 UTC] mike@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: mike
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ On 5_2 and 5_3, there is an inconsistency between ob_flush() and ob_get_flush() when attempting to flush a buffer created with the flag $erase=false: - ob_get_flush() raises a notice and does NOT flush the buffer; - ob_flush() DOES flush the buffer. Note that on HEAD, both ob_get_flush() and ob_flush() raise a notice and do NOT flush the buffer. I think the behaviour in HEAD is correct. Here's a simple patch for 5_3 that resolves the inconsistency and makes it behave more like HEAD: Index: output.c =================================================================== RCS file: /repository/php-src/main/output.c,v retrieving revision 1.167.2.3.2.4.2.9 diff -u -w -p -r1.167.2.3.2.4.2.9 output.c --- output.c 18 Aug 2008 07:46:31 -0000 1.167.2.3.2.4.2.9 +++ output.c 18 Dec 2008 11:30:01 -0000 @@ -774,6 +774,10 @@ PHP_FUNCTION(ob_flush) php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush."); RETURN_FALSE; } + if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer %s", OG(active_ob_buffer).handler_name); + RETURN_FALSE; + } php_end_ob_buffer(1, 1 TSRMLS_CC); RETURN_TRUE; More generally, the behaviour of output buffering functions when dealing with unerasable buffers could benefit from better docs. I will raise a separate doc bug with some suggestions. Reproduce code: --------------- <?php function callback($string) { static $callback_invocations; $callback_invocations++; return "[callback:$callback_invocations]$string\n"; } ob_start('callback', 0, false); echo "Attempt to flush unerasable buffer - should fail... "; var_dump(ob_flush()); // Check content of buffer after flush - if flush failed it should still contain the string above. var_dump(ob_get_contents()); ?> Expected result: ---------------- [callback:1]Attempt to flush unerasable buffer - should fail... Notice: ob_flush(): failed to flush buffer callback in %s on line 11 bool(false) string(%d) "Attempt to flush unerasable buffer - should fail... Notice: ob_flush(): failed to flush buffer callback in %s on line 11 bool(false) " Actual result: -------------- [callback:1]Attempt to flush unerasable buffer - should fail... [callback:2]bool(true) string(11) "bool(true) "