From: robin_fernandes at uk dot ibm dot com
Operating system: *
PHP version: 6CVS-2008-12-18 (snap)
PHP Bug Type: Output Control
Bug description: Unexpected behaviour in HEAD when output buffer callback
returns null
Description:
------------
In HEAD, the original input is sent to the output when the output buffer
callback returns NULL. The docs for ob_start() only state this should
happen when it returns FALSE - not NULL:
"If output_callback returns FALSE original input is sent to the
browser."
On PHP 5_2 and 5_3, the empty string is sent to the output when the output
buffer callback returns NULL.
If the 5_2 & 5_3 behaviour is correct, here is a patch for HEAD :
Index: output.c
===================================================================
RCS file: /repository/php-src/main/output.c,v
retrieving revision 1.214
diff -u -w -p -r1.214 output.c
--- output.c 18 Aug 2008 07:45:59 -0000 1.214
+++ output.c 18 Dec 2008 14:08:53 -0000
@@ -983,7 +983,7 @@ static inline php_output_handler_status_
ZVAL_LONG(ob_mode, (long) context->op);
zend_fcall_info_argn(&handler->func.user->fci
TSRMLS_CC, 2, &ob_data,
&ob_mode);
-#define PHP_OUTPUT_USER_SUCCESS(retval) (retval && (Z_TYPE_P(retval) !=
IS_NULL) && (Z_TYPE_P(retval) != IS_BOOL || Z_BVAL_P(retval)))
+#define PHP_OUTPUT_USER_SUCCESS(retval) (retval && !(Z_TYPE_P(retval) ==
IS_BOOL && Z_BVAL_P(retval)==0))
if (SUCCESS ==
zend_fcall_info_call(&handler->func.user->fci,
&handler->func.user->fcc, &retval, NULL TSRMLS_CC) &&
PHP_OUTPUT_USER_SUCCESS(retval)) {
/* user handler may have returned TRUE */
status = PHP_OUTPUT_HANDLER_NO_DATA;
If HEAD's current behaviour is as intended, the docs should be updated to
describe the new behaviour in PHP6.
Reproduce code:
---------------
<?php
function return_null($string) {
return null;
}
ob_start('return_null');
echo "You shouldn't see this.\n";
ob_end_flush();
echo 'done';
?>
Expected result:
----------------
done
Actual result:
--------------
You shouldn't see this.
done
--
Edit bug report at http://bugs.php.net/?id=46900&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46900&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46900&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46900&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46900&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46900&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46900&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46900&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46900&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46900&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46900&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46900&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46900&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46900&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46900&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46900&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46900&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46900&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46900&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46900&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46900&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46900&r=mysqlcfg