Skip to content

Commit

Permalink
fix #13 output buffering not working during execution
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Nov 20, 2013
1 parent f92de15 commit 7a81ed4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
14 changes: 12 additions & 2 deletions phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {
}
/* }}} */

static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int length TSRMLS_DC) /* {{{ */
{
return phpdbg_write(message);
} /* }}} */

static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */
{
fflush(stdout);
} /* }}} */

/* {{{ sapi_module_struct phpdbg_sapi_module
*/
static sapi_module_struct phpdbg_sapi_module = {
Expand All @@ -346,8 +356,8 @@ static sapi_module_struct phpdbg_sapi_module = {
NULL, /* activate */
php_sapi_phpdbg_deactivate, /* deactivate */

NULL, /* unbuffered write */
NULL, /* flush */
php_sapi_phpdbg_ub_write, /* unbuffered write */
php_sapi_phpdbg_flush, /* flush */
NULL, /* get uid */
NULL, /* getenv */

Expand Down
2 changes: 2 additions & 0 deletions phpdbg_prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,10 @@ static PHPDBG_COMMAND(run) /* {{{ */
&PHPDBG_G(seek));

zend_try {
php_output_activate(TSRMLS_C);
zend_execute(
EG(active_op_array) TSRMLS_CC);
php_output_deactivate(TSRMLS_C);
} zend_catch {
EG(active_op_array) = orig_op_array;
EG(opline_ptr) = orig_opline;
Expand Down
7 changes: 7 additions & 0 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ function test() {

if (isset($dump))
var_dump($_SERVER);

echo 'Start';
ob_start();
echo 'Hello';
$b = ob_get_clean();
echo 'End';
echo $b;
?>

0 comments on commit 7a81ed4

Please sign in to comment.