Skip to content

Commit 7a81ed4

Browse files
committed
fix #13 output buffering not working during execution
1 parent f92de15 commit 7a81ed4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

phpdbg.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {
334334
}
335335
/* }}} */
336336

337+
static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int length TSRMLS_DC) /* {{{ */
338+
{
339+
return phpdbg_write(message);
340+
} /* }}} */
341+
342+
static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */
343+
{
344+
fflush(stdout);
345+
} /* }}} */
346+
337347
/* {{{ sapi_module_struct phpdbg_sapi_module
338348
*/
339349
static sapi_module_struct phpdbg_sapi_module = {
@@ -346,8 +356,8 @@ static sapi_module_struct phpdbg_sapi_module = {
346356
NULL, /* activate */
347357
php_sapi_phpdbg_deactivate, /* deactivate */
348358

349-
NULL, /* unbuffered write */
350-
NULL, /* flush */
359+
php_sapi_phpdbg_ub_write, /* unbuffered write */
360+
php_sapi_phpdbg_flush, /* flush */
351361
NULL, /* get uid */
352362
NULL, /* getenv */
353363

phpdbg_prompt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,10 @@ static PHPDBG_COMMAND(run) /* {{{ */
477477
&PHPDBG_G(seek));
478478

479479
zend_try {
480+
php_output_activate(TSRMLS_C);
480481
zend_execute(
481482
EG(active_op_array) TSRMLS_CC);
483+
php_output_deactivate(TSRMLS_C);
482484
} zend_catch {
483485
EG(active_op_array) = orig_op_array;
484486
EG(opline_ptr) = orig_opline;

test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,11 @@ function test() {
3838

3939
if (isset($dump))
4040
var_dump($_SERVER);
41+
42+
echo 'Start';
43+
ob_start();
44+
echo 'Hello';
45+
$b = ob_get_clean();
46+
echo 'End';
47+
echo $b;
4148
?>

0 commit comments

Comments
 (0)