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 (chunk_size < 0) {
chunk_size = 0;
+ } else if (chunk_size == 1) {
+ chunk_size = 4096;
}
if (SUCCESS != php_output_start_user(output_handler, chunk_size, flags TSRMLS_CC)) {
--- /dev/null
+--TEST--
+Bug #46900 (Unexpected behaviour in HEAD when output buffer callback returns null)
+--FILE--
+<?php
+function return_null($string) {
+ return null;
+}
+
+ob_start('return_null');
+echo "You shouldn't see this.\n";
+ob_end_flush();
+
+echo 'done';
+?>
+--EXPECTF--
+done
\ No newline at end of file
--- /dev/null
+--TEST--
+Bug #46903 (ob_start(): Special $chunk_size value of 1 is not honoured in HEAD)
+--FILE--
+<?php
+function flushCounter($input) {
+ static $counter=0;
+ return '[' . ++$counter . "] $input \n";
+}
+
+// This should set the buffer size to 4096
+ob_start('flushCounter', 1);
+
+// Get the buffer size:
+$bufferInfo = ob_get_status(true);
+var_dump($bufferInfo[0]['chunk_size']);
+
+// If the buffer size is >1, these two chars should
+// come out as part of a single flush:
+echo "1";
+echo "2";
+?>
+--EXPECTF--
+[1] int(4096)
+12
\ No newline at end of file
output buffering - failure
--FILE--
<?php
-/*
- * apparently the error handler cannot get the current function name on shutdown
- */
ob_start("str_rot13");
echo "foo\n";
+// str_rot13 expects 1 param and returns NULL when passed 2 params.
+// It is invoked with 2 params when used as an OB callback.
+// Therefore, there will be no data in the buffer. This is expected: see bug 46900.
+ob_end_flush();
+
+// Show the error.
+print_r(error_get_last());
?>
--EXPECTF--
-foo
-
-Warning: (null)() expects exactly 1 parameter, 2 given in %s on line %d
+Array
+(
+ [type] => 2
+ [message] => str_rot13() expects exactly 1 parameter, 2 given
+ [file] => %s
+ [line] => 7
+)
\ No newline at end of file
<?php
ob_start("str_rot13", 1);
echo "foo\n";
+// str_rot13 expects 1 param and returns NULL when passed 2 params.
+// It is invoked with 2 params when used as an OB callback.
+// Therefore, there will be no data in the buffer. This is expected: see bug 46900.
+ob_end_flush();
+
+// Show the error.
+print_r(error_get_last());
?>
--EXPECTF--
-foo
-
-Warning: str_rot13() expects exactly 1 parameter, 2 given in %s on line %d
+Array
+(
+ [type] => 2
+ [message] => str_rot13() expects exactly 1 parameter, 2 given
+ [file] => %s
+ [line] => 7
+)
\ No newline at end of file
--TEST--
ob_start(): Check behaviour with various callback return values.
---XFAIL--
-PHP6 behaves differently from PHP5 when callback returns null. See bug 46900.
--FILE--
<?php
function return_empty_string($string) {
--TEST--
ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
---XFAIL--
-Special behaviour when chunk_size set to 1 is not honoured on PHP6. See bug 46903.
--FILE--
<?php
/*