Skip to content

Commit 340c7fd

Browse files
Only disable the problematic output handler
And update tests
1 parent f4c3fde commit 340c7fd

File tree

11 files changed

+48
-15
lines changed

11 files changed

+48
-15
lines changed

Zend/tests/concat/bug79836.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ $c .= [];
1414
ob_end_clean();
1515
echo $counter . "\n";
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
19+
20+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
21+
22+
Deprecated: ob_end_clean(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
1823
3

Zend/tests/concat/bug79836_1.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ $x = $c . $x;
1414
ob_end_clean();
1515
echo "Done\n";
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
19+
20+
Deprecated: ob_end_clean(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
1821
Done

Zend/tests/concat/bug79836_2.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ $x = $c . $xxx;
2121
ob_end_clean();
2222
echo $x . "\n";
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: X::__toString(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
26+
27+
Deprecated: ob_end_clean(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
2528
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc

Zend/tests/declare/gh18033_2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ ob_start(function() {
1313
);
1414
});
1515
?>
16-
--EXPECT--
16+
--EXPECTF--
17+
Deprecated: PHP Request Shutdown: Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d

Zend/tests/gh11189.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ while (1) {
2626
?>
2727
--EXPECTF--
2828
Success
29+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
30+
2931
Fatal error: Allowed memory size of %s bytes exhausted%s(tried to allocate %s bytes) in %s on line %d

Zend/tests/gh11189_1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ while (1) {
2626
?>
2727
--EXPECTF--
2828
Success
29+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
30+
2931
Fatal error: Allowed memory size of %s bytes exhausted%s(tried to allocate %s bytes) in %s on line %d

Zend/tests/gh16408.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ $c .= [];
1212
ob_end_clean();
1313
echo $counter . "\n";
1414
?>
15-
--EXPECT--
15+
--EXPECTF--
16+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
17+
18+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
19+
20+
Deprecated: ob_end_clean(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
1621
3

ext/session/tests/user_session_module/bug61728.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ class MySessionHandler implements SessionHandlerInterface {
4040
session_set_save_handler(new MySessionHandler());
4141
session_start();
4242
?>
43-
--EXPECT--
43+
--EXPECTF--
44+
Deprecated: ob_end_flush(): Returning a non-string result from user output handler output_html is deprecated in %s on line %d
4445
8

main/output.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,16 +962,16 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
962962

963963
if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && Z_TYPE(retval) != IS_UNDEF) {
964964
if (Z_TYPE(retval) != IS_STRING) {
965-
// Make sure that we don't get lost in an output buffer
966-
int old_flags = OG(flags);
967-
OG(flags) = old_flags & (~PHP_OUTPUT_ACTIVATED);
965+
// Make sure that we don't get lost in the current output buffer
966+
// by disabling it
967+
handler->flags |= PHP_OUTPUT_HANDLER_DISABLED;
968968
php_error_docref(
969969
NULL,
970970
E_DEPRECATED,
971971
"Returning a non-string result from user output handler %s is deprecated",
972972
ZSTR_VAL(handler->name)
973973
);
974-
OG(flags) = old_flags;
974+
handler->flags &= (~PHP_OUTPUT_HANDLER_DISABLED);
975975
}
976976
if (Z_TYPE(retval) == IS_FALSE) {
977977
/* call failed, pass internal buffer along */

sapi/cli/tests/gh8827-002.phpt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ print "STDOUT:\n";
3232
fclose(STDOUT);
3333
var_dump(@fopen('php://stdout', 'a'));
3434
?>
35-
--EXPECT--
35+
--EXPECTF--
3636
STDIN:
37+
38+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
3739
bool(false)
40+
41+
Deprecated: var_dump(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
3842
STDERR:
43+
44+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
3945
bool(false)
46+
47+
Deprecated: var_dump(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
4048
STDOUT:
49+
50+
Deprecated: main(): Returning a non-string result from user output handler Closure::__invoke is deprecated in %s on line %d
4151
bool(false)

0 commit comments

Comments
 (0)