|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-04 10:53 UTC] peacech at gmail dot com
Description:
------------
Running test script below with PHP 5.4 outputs
""
Running test script below with PHP 5.3 outputs
"hello"
Test script:
---------------
<?php
$buffer = -1;
function callback($output)
{
global $buffer;
$buffer = $output;
return $output;
}
ob_start('callback');
echo 'hello';
ob_get_clean();
var_dump($buffer);
Expected result:
----------------
"hello"
Actual result:
--------------
""
Patchespass-cleaned-output-to-callback (last revision 2012-06-08 07:51 UTC by casper at langemeijer dot eu)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
Unless ob_start callback specification has changed that for ob_clean/ob_end_clean, the output is discarded before calling the callback, then this is a bug. And I have scan the PHP 5.4 changelog and couldn't find anything mentioning this change. So let me help by showing where the problem is In line 1226 of output.c in the distributed PHP 5.4.0 source, if (flags & PHP_OUTPUT_POP_DISCARD) { context.op |= PHP_OUTPUT_HANDLER_CLEAN; orphan->buffer.used = 0; } php_output_handler_op(orphan, &context); orphan->buffer.used should not be set to 0 before calling the callback, otherwise the callback will be called with empty buffer. And likewise in line 300 in php_output_clean So, no, it isn't about appending $output to $buffer.