diff --git a/UPGRADING b/UPGRADING index b18b6825224b0..f95ca587594a5 100644 --- a/UPGRADING +++ b/UPGRADING @@ -361,16 +361,10 @@ PHP 8.5 UPGRADE NOTES ======================================== - Core: - . Returning a non-string from a user output handler is deprecated. The - deprecation warning will bypass the handler with the bad return to ensure - it is visible; if there are nested output handlers the next one will still - be used. - RFC: https://wiki.php.net/rfc/deprecations_php_8_4 . Trying to produce output (e.g. with `echo`) within a user output handler is deprecated. The deprecation warning will bypass the handler producing the output to ensure it is visible; if there are nested output handlers the next - one will still be used. If a user output handler returns a non-string and - produces output, the warning about producing an output is emitted first. + one will still be used. RFC: https://wiki.php.net/rfc/deprecations_php_8_4 . Non-canonical cast names (boolean), (integer), (double), and (binary) have been deprecated, use (bool), (int), (float), and (string) respectively. diff --git a/main/output.c b/main/output.c index c75b09e86c18b..653b457e9b641 100644 --- a/main/output.c +++ b/main/output.c @@ -956,7 +956,6 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl if (handler->flags & PHP_OUTPUT_HANDLER_USER) { zval ob_args[2]; zval retval; - ZVAL_UNDEF(&retval); /* ob_data */ ZVAL_STRINGL(&ob_args[0], handler->buffer.data, handler->buffer.used); @@ -969,17 +968,10 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl handler->func.user->fci.retval = &retval; if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && Z_TYPE(retval) != IS_UNDEF) { - if (Z_TYPE(retval) != IS_STRING || handler->flags & PHP_OUTPUT_HANDLER_PRODUCED_OUTPUT) { + if (handler->flags & PHP_OUTPUT_HANDLER_PRODUCED_OUTPUT) { // Make sure that we don't get lost in the current output buffer // by disabling it handler->flags |= PHP_OUTPUT_HANDLER_DISABLED; - // Make sure we keep a reference to the handler name in - // case - // * The handler produced output *and* returned a non-string - // * The first deprecation message causes the handler to - // be removed - zend_string *handler_name = handler->name; - zend_string_addref(handler_name); if (handler->flags & PHP_OUTPUT_HANDLER_PRODUCED_OUTPUT) { // The handler might not always produce output handler->flags &= ~PHP_OUTPUT_HANDLER_PRODUCED_OUTPUT; @@ -987,18 +979,9 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl NULL, E_DEPRECATED, "Producing output from user output handler %s is deprecated", - ZSTR_VAL(handler_name) - ); - } - if (Z_TYPE(retval) != IS_STRING) { - php_error_docref( - NULL, - E_DEPRECATED, - "Returning a non-string result from user output handler %s is deprecated", - ZSTR_VAL(handler_name) + ZSTR_VAL(handler->name) ); } - zend_string_release(handler_name); // Check if the handler is still in the list of handlers to // determine if the PHP_OUTPUT_HANDLER_DISABLED flag can diff --git a/tests/output/ob_start_basic_002.phpt b/tests/output/ob_start_basic_002.phpt index e9af2b5e1904c..700dab5d3c381 100644 --- a/tests/output/ob_start_basic_002.phpt +++ b/tests/output/ob_start_basic_002.phpt @@ -35,24 +35,19 @@ foreach ($callbacks as $callback) { } ?> ---EXPECTF-- +--EXPECT-- --> Use callback 'return_empty_string': --> Use callback 'return_false': - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s on line %d My output. --> Use callback 'return_null': -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s on line %d - --> Use callback 'return_string': I stole your output. --> Use callback 'return_zero': - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s on line %d 0 + diff --git a/tests/output/ob_start_callback_bad_return/exception_handler.phpt b/tests/output/ob_start_callback_bad_return/exception_handler.phpt deleted file mode 100644 index eef3fccc77ec0..0000000000000 --- a/tests/output/ob_start_callback_bad_return/exception_handler.phpt +++ /dev/null @@ -1,147 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation converted to exception [bad return] ---FILE-- -val; - } -} - -$log = []; - -set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { - throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); -}); - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return null; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return true; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return 0; -} - -function return_non_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return new NotStringable($string); -} - -function return_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return new IsStringable($string); -} - -$cases = [ - 'return_null', - 'return_false', - 'return_true', - 'return_zero', - 'return_non_stringable', - 'return_stringable', -]; -foreach ($cases as $case) { - $log = []; - echo "\n\nTesting: $case\n"; - ob_start($case); - echo "Inside of $case\n"; - try { - ob_end_flush(); - } catch (\ErrorException $e) { - echo $e . "\n"; - } - echo "\nEnd of $case, log was:\n"; - echo implode("\n", $log); -} - -?> ---EXPECTF-- -Testing: return_null -ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_null, log was: -return_null: <<>> - -Testing: return_false -Inside of return_false -ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_false, log was: -return_false: <<>> - -Testing: return_true -ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_true, log was: -return_true: <<>> - -Testing: return_zero -0ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_zero, log was: -return_zero: <<>> - -Testing: return_non_stringable -ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_non_stringable is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, 69) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_non_stringable, log was: -return_non_stringable: <<>> - -Testing: return_stringable -ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_stringable is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, 69) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_stringable, log was: -return_stringable: <<>> diff --git a/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt b/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt deleted file mode 100644 index 64d7f805687b2..0000000000000 --- a/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with nested deprecation converted to exception [bad return] ---FILE-- -val; - } -} - -$log = []; - -set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { - throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); -}); - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return null; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return true; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return 0; -} - -function return_non_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return new NotStringable($string); -} - -function return_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return new IsStringable($string); -} - -ob_start('return_null'); -ob_start('return_false'); -ob_start('return_true'); -ob_start('return_zero'); -ob_start('return_non_stringable'); -ob_start('return_stringable'); - -echo "In all of them\n\n"; -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_stringable handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_non_stringable handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_zero handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_true handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_false handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_null handler\n\n"; - -echo "All handlers are over\n\n"; -echo implode("\n", $log); - -?> ---EXPECT-- -ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated -Ended return_null handler - -All handlers are over - -return_stringable: <<>> -return_non_stringable: <<>> -return_zero: <<>> -return_true: <<<0ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated -Ended return_zero handler - ->>> -return_false: <<>> -return_null: <<>> diff --git a/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt deleted file mode 100644 index 32702a58fcc14..0000000000000 --- a/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns false) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt deleted file mode 100644 index 0d87358da1b9d..0000000000000 --- a/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns stringable object) ---INI-- -memory_limit=2M ---FILE-- -val; - } -} - -ob_start(function() { - // We are out of memory, now trigger a deprecation - return new IsStringable(""); -}); - -$a = []; -// trigger OOM in a resize operation -while (1) { - $a[] = 1; -} - -?> ---EXPECTF-- -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt deleted file mode 100644 index 65d8ccfbcba61..0000000000000 --- a/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns non-stringable object) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d - -Fatal error: Uncaught Error: Object of class NotStringable could not be converted to string in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt deleted file mode 100644 index 5ad19826c4ac7..0000000000000 --- a/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns true) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt deleted file mode 100644 index 1bc7279c71d35..0000000000000 --- a/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns zero) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt b/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt deleted file mode 100644 index 100abe7d79d18..0000000000000 --- a/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt +++ /dev/null @@ -1,106 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with multiple nested handlers with bad return values ---FILE-- ->>"; - return $string; -} - -function return_empty_string($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return ""; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return true; -} - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return null; -} - -function return_string($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return "I stole your output."; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - return 0; -} - -ob_start('return_given_string'); -ob_start('return_empty_string'); -ob_start('return_false'); -ob_start('return_true'); -ob_start('return_null'); -ob_start('return_string'); -ob_start('return_zero'); - -echo "Testing..."; - -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); - -echo "\n\nLog:\n"; -echo implode("\n", $log); -?> ---EXPECTF-- -Deprecated: ob_end_flush(): Producing output from user output handler return_given_string is deprecated in %s on line %d3 - -Deprecated: ob_end_flush(): Producing output from user output handler return_empty_string is deprecated in %s on line %d2 - - -Log: -return_zero: <<>> -return_string: <<< -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s on line %d -0>>> -return_null: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_string is deprecated in %s on line %d -I stole your output.>>> -return_true: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_null is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s on line %d ->>> -return_false: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_true is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d ->>> -return_empty_string: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_false is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Producing output from user output handler return_true is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d ->>> -return_given_string: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_empty_string is deprecated in %s on line %d2 ->>> diff --git a/tests/output/ob_start_callback_output_and_bad_return/exception_handler.phpt b/tests/output/ob_start_callback_output_and_bad_return/exception_handler.phpt deleted file mode 100644 index 2b018c792a52c..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/exception_handler.phpt +++ /dev/null @@ -1,153 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation converted to exception [bad return + produce output] ---FILE-- -val; - } -} - -$log = []; - -set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { - throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); -}); - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return null; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return true; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return 0; -} - -function return_non_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return new NotStringable($string); -} - -function return_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return new IsStringable($string); -} - -$cases = [ - 'return_null', - 'return_false', - 'return_true', - 'return_zero', - 'return_non_stringable', - 'return_stringable', -]; -foreach ($cases as $case) { - $log = []; - echo "\n\nTesting: $case\n"; - ob_start($case); - echo "Inside of $case\n"; - try { - ob_end_flush(); - } catch (\ErrorException $e) { - echo $e . "\n"; - } - echo "\nEnd of $case, log was:\n"; - echo implode("\n", $log); -} - -?> ---EXPECTF-- -Testing: return_null -ErrorException: ob_end_flush(): Producing output from user output handler return_null is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_null, log was: -return_null: <<>> - -Testing: return_false -Inside of return_false -return_falseErrorException: ob_end_flush(): Producing output from user output handler return_false is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_false, log was: -return_false: <<>> - -Testing: return_true -ErrorException: ob_end_flush(): Producing output from user output handler return_true is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_true, log was: -return_true: <<>> - -Testing: return_zero -0ErrorException: ob_end_flush(): Producing output from user output handler return_zero is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_zero, log was: -return_zero: <<>> - -Testing: return_non_stringable -ErrorException: ob_end_flush(): Producing output from user output handler return_non_stringable is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_non_stringable, log was: -return_non_stringable: <<>> - -Testing: return_stringable -ErrorException: ob_end_flush(): Producing output from user output handler return_stringable is deprecated in %s:%d -Stack trace: -#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) -#1 %s(%d): ob_end_flush() -#2 {main} - -End of return_stringable, log was: -return_stringable: <<>> diff --git a/tests/output/ob_start_callback_output_and_bad_return/exception_handler_nested.phpt b/tests/output/ob_start_callback_output_and_bad_return/exception_handler_nested.phpt deleted file mode 100644 index 7eb060acc2133..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/exception_handler_nested.phpt +++ /dev/null @@ -1,149 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with nested deprecation converted to exception [bad return + produce output] ---FILE-- -val; - } -} - -$log = []; - -set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { - throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); -}); - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return null; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return true; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return 0; -} - -function return_non_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return new NotStringable($string); -} - -function return_stringable($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return new IsStringable($string); -} - -ob_start('return_null'); -ob_start('return_false'); -ob_start('return_true'); -ob_start('return_zero'); -ob_start('return_non_stringable'); -ob_start('return_stringable'); - -echo "In all of them\n\n"; -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_stringable handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_non_stringable handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_zero handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_true handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_false handler\n\n"; - -try { - ob_end_flush(); -} catch (\ErrorException $e) { - echo $e->getMessage() . "\n"; -} -echo "Ended return_null handler\n\n"; - -echo "All handlers are over\n\n"; -echo implode("\n", $log); - -?> ---EXPECT-- -ob_end_flush(): Producing output from user output handler return_null is deprecated -Ended return_null handler - -All handlers are over - -return_stringable: <<>> -return_non_stringable: <<>> -return_zero: <<>> -return_true: <<<0ob_end_flush(): Producing output from user output handler return_zero is deprecated -Ended return_zero handler - ->>> -return_false: <<>> -return_null: <<>> diff --git a/tests/output/ob_start_callback_output_and_bad_return/handler_false_removed.phpt b/tests/output/ob_start_callback_output_and_bad_return/handler_false_removed.phpt deleted file mode 100644 index 78c736b80cd14..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/handler_false_removed.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns false + produces output) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Producing output from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_output_and_bad_return/handler_is_stringable_removed.phpt b/tests/output/ob_start_callback_output_and_bad_return/handler_is_stringable_removed.phpt deleted file mode 100644 index 9da82bc147e19..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/handler_is_stringable_removed.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns stringable object + produces output) ---INI-- -memory_limit=2M ---FILE-- -val; - } -} - -ob_start(function() { - // We are out of memory, now trigger a deprecation - echo "IN HANDLER\n"; - return new IsStringable(""); -}); - -$a = []; -// trigger OOM in a resize operation -while (1) { - $a[] = 1; -} - -?> ---EXPECTF-- -Deprecated: main(): Producing output from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_output_and_bad_return/handler_non_stringable_removed.phpt b/tests/output/ob_start_callback_output_and_bad_return/handler_non_stringable_removed.phpt deleted file mode 100644 index 476acaee9c3a3..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/handler_non_stringable_removed.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns non-stringable object + produces output) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Producing output from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d - -Fatal error: Uncaught Error: Object of class NotStringable could not be converted to string in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d diff --git a/tests/output/ob_start_callback_output_and_bad_return/handler_true_removed.phpt b/tests/output/ob_start_callback_output_and_bad_return/handler_true_removed.phpt deleted file mode 100644 index 2b0218341c9b8..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/handler_true_removed.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns true + produces output) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Producing output from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_output_and_bad_return/handler_zero_removed.phpt b/tests/output/ob_start_callback_output_and_bad_return/handler_zero_removed.phpt deleted file mode 100644 index 8681a846a3648..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/handler_zero_removed.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns zero + produces output) ---INI-- -memory_limit=2M ---FILE-- - ---EXPECTF-- -Deprecated: main(): Producing output from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_output_and_bad_return/multiple_handlers.phpt b/tests/output/ob_start_callback_output_and_bad_return/multiple_handlers.phpt deleted file mode 100644 index 94d5d34c03830..0000000000000 --- a/tests/output/ob_start_callback_output_and_bad_return/multiple_handlers.phpt +++ /dev/null @@ -1,115 +0,0 @@ ---TEST-- -ob_start(): Check behaviour with multiple nested handlers with bad return values and output ---FILE-- ->>"; - echo __FUNCTION__; - return $string; -} - -function return_empty_string($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return ""; -} - -function return_false($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return false; -} - -function return_true($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return true; -} - -function return_null($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return null; -} - -function return_string($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return "I stole your output."; -} - -function return_zero($string) { - global $log; - $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; - echo __FUNCTION__; - return 0; -} - -ob_start('return_given_string'); -ob_start('return_empty_string'); -ob_start('return_false'); -ob_start('return_true'); -ob_start('return_null'); -ob_start('return_string'); -ob_start('return_zero'); - -echo "Testing..."; - -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); -ob_end_flush(); - -echo "\n\nLog:\n"; -echo implode("\n", $log); -?> ---EXPECTF-- -Deprecated: ob_end_flush(): Producing output from user output handler return_given_string is deprecated in %s on line %d0 - -Deprecated: ob_end_flush(): Producing output from user output handler return_empty_string is deprecated in %s on line %d9 - - -Log: -return_zero: <<>> -return_string: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_zero is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s on line %d -0>>> -return_null: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_string is deprecated in %s on line %d5 -I stole your output.>>> -return_true: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_null is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s on line %d ->>> -return_false: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_true is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d ->>> -return_empty_string: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_false is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Producing output from user output handler return_true is deprecated in %s on line %d - -Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d -return_false>>> -return_given_string: <<< -Deprecated: ob_end_flush(): Producing output from user output handler return_empty_string is deprecated in %s on line %d9 ->>>