Skip to content

Commit 7f1b4eb

Browse files
committed
Address review comments
1 parent 433d47d commit 7f1b4eb

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

main/SAPI.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,15 @@ PHP_FUNCTION(header_register_callback)
117117

118118
if (ZEND_FCC_INITIALIZED(SG(send_header_fcc))) {
119119
zend_fcc_dtor(&SG(send_header_fcc));
120-
SG(send_header_fcc) = empty_fcall_info_cache;
121120
}
122121

123122
/* Don't store callback if headers have already been sent:
124123
* It won't get used and we won't have a chance to release it. */
125124
if (UNEXPECTED(SG(headers_sent))) {
126125
zend_release_fcall_info_cache(&fcc);
126+
} else {
127+
zend_fcc_dup(&SG(send_header_fcc), &fcc);
127128
}
128-
129-
zend_fcc_dup(&SG(send_header_fcc), &fcc);
130129
RETURN_TRUE;
131130
}
132131
/* }}} */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test header_register_callback
3+
--FILE--
4+
<?php
5+
class TrampolineTest {
6+
public function __call(string $name, array $arguments) {
7+
echo 'Trampoline for ', $name, PHP_EOL;
8+
}
9+
}
10+
$o = new TrampolineTest();
11+
$callback = [$o, 'trampoline'];
12+
13+
echo "Send headers.\n";
14+
header_register_callback($callback);
15+
?>
16+
--EXPECT--
17+
Send headers.

0 commit comments

Comments
 (0)