diff --git a/tests/bug00790-2.phpt b/tests/bug00790-2.phpt
index 0fd3a6fbe..8d8898172 100644
--- a/tests/bug00790-2.phpt
+++ b/tests/bug00790-2.phpt
@@ -24,18 +24,12 @@ dbgpRun( $data, $commands );
-> run -i 2
-
+
-> run -i 3
-
-
-
-
-
-
diff --git a/xdebug.c b/xdebug.c
index c7773ec12..2e8d69e8c 100644
--- a/xdebug.c
+++ b/xdebug.c
@@ -77,6 +77,9 @@ void (*xdebug_new_error_cb)(int type, const char *error_filename, const uint err
void xdebug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
static int xdebug_header_handler(sapi_header_struct *h XG_SAPI_HEADER_OP_DC, sapi_headers_struct *s TSRMLS_DC);
+#if PHP_VERSION_ID >= 50400
+static int xdebug_ub_write(const char *string, unsigned int lenght TSRMLS_DC);
+#endif
static void xdebug_throw_exception_hook(zval *exception TSRMLS_DC);
int xdebug_exit_handler(ZEND_OPCODE_HANDLER_ARGS);
@@ -85,6 +88,9 @@ int zend_xdebug_initialised = 0;
int zend_xdebug_global_offset = -1;
int (*xdebug_orig_header_handler)(sapi_header_struct *h XG_SAPI_HEADER_OP_DC, sapi_headers_struct *s TSRMLS_DC);
+#if PHP_VERSION_ID >= 50400
+int (*xdebug_orig_ub_write)(const char *string, unsigned int len TSRMLS_DC);
+#endif
static int xdebug_trigger_enabled(int setting, char *var_name TSRMLS_DC);
@@ -339,6 +345,14 @@ static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC)
sapi_module.header_handler = xdebug_header_handler;
}
xg->headers = NULL;
+
+#if PHP_VERSION_ID >= 50400
+ /* Capturing output */
+ if (sapi_module.ub_write != xdebug_ub_write) {
+ xdebug_orig_ub_write = sapi_module.ub_write;
+ sapi_module.ub_write = xdebug_ub_write;
+ }
+#endif
}
static void php_xdebug_shutdown_globals (zend_xdebug_globals *xg TSRMLS_DC)
@@ -673,6 +687,12 @@ PHP_MINIT_FUNCTION(xdebug)
xdebug_orig_header_handler = sapi_module.header_handler;
sapi_module.header_handler = xdebug_header_handler;
}
+# if PHP_VERSION_ID >= 50400
+ if (sapi_module.ub_write != xdebug_ub_write) {
+ xdebug_orig_ub_write = sapi_module.ub_write;
+ sapi_module.ub_write = xdebug_ub_write;
+ }
+# endif
#endif
return SUCCESS;
@@ -773,20 +793,16 @@ static void xdebug_stack_element_dtor(void *dummy, void *elem)
#endif
#if PHP_VERSION_ID >= 50400
-int xdebug_output_handler(void **handler_context, php_output_context *c)
+int xdebug_ub_write(const char *string, unsigned int length TSRMLS_DC)
{
TSRMLS_FETCH();
if (XG(remote_enabled)) {
- XG(context).handler->remote_stream_output(c TSRMLS_CC);
- return SUCCESS;
- } else {
- c->out.data = c->in.data;
- c->out.size = c->in.used;
- c->out.used = c->in.used;
- c->out.free = 0;
- return SUCCESS;
+ if (-1 == XG(context).handler->remote_stream_output(string, length TSRMLS_CC)) {
+ return 0;
+ }
}
+ return xdebug_orig_ub_write(string, length);
}
#endif
@@ -795,9 +811,6 @@ PHP_RINIT_FUNCTION(xdebug)
zend_function *orig;
char *idekey;
zval **dummy;
-#if PHP_VERSION_ID >= 50400
- php_output_handler *h;
-#endif
/* get xdebug ini entries from the environment also */
XG(ide_key) = NULL;
@@ -917,13 +930,6 @@ PHP_RINIT_FUNCTION(xdebug)
XG(headers) = xdebug_llist_alloc(xdebug_llist_string_dtor);
-#if PHP_VERSION_ID >= 50400
- h = php_output_handler_create_internal("xdebug", sizeof("xdebug"), xdebug_output_handler, 1, 0 TSRMLS_CC);
- php_output_handler_start(h TSRMLS_CC);
-
- XG(stdout_mode) = 0;
-#endif
-
return SUCCESS;
}
diff --git a/xdebug_handler_dbgp.c b/xdebug_handler_dbgp.c
index a8d08870e..8de2aecfa 100644
--- a/xdebug_handler_dbgp.c
+++ b/xdebug_handler_dbgp.c
@@ -2700,23 +2700,16 @@ int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file,
}
#if PHP_VERSION_ID >= 50400
-void xdebug_dbgp_stream_output(php_output_context *c TSRMLS_DC)
+int xdebug_dbgp_stream_output(const char *string, unsigned int length TSRMLS_DC)
{
- if (XG(stdout_mode) == 0 || XG(stdout_mode) == 1) {
- c->out.data = c->in.data;
- c->out.size = c->in.used;
- c->out.used = c->in.used;
- c->out.free = 0;
- } else {
- c->out.data = estrdup("");
- c->out.size = 0;
- c->out.used = 0;
- c->out.free = 1;
+ if ((XG(stdout_mode) == 1 || XG(stdout_mode) == 2) && length) {
+ xdebug_send_stream("stdout", string, length TSRMLS_CC);
}
- if ((XG(stdout_mode) == 1 || XG(stdout_mode) == 2) && c->in.used) {
- xdebug_send_stream("stdout", c->in.data, c->in.used TSRMLS_CC);
+ if (XG(stdout_mode) == 0 || XG(stdout_mode) == 1) {
+ return 0;
}
+ return -1;
}
#endif
diff --git a/xdebug_handler_dbgp.h b/xdebug_handler_dbgp.h
index 28b3b3d34..281111905 100644
--- a/xdebug_handler_dbgp.h
+++ b/xdebug_handler_dbgp.h
@@ -93,7 +93,7 @@ int xdebug_dbgp_deinit(xdebug_con *context);
int xdebug_dbgp_error(xdebug_con *context, int type, char *exception_type, char *message, const char *location, const uint line, xdebug_llist *stack);
int xdebug_dbgp_breakpoint(xdebug_con *context, xdebug_llist *stack, char *file, long lineno, int type, char *exception, char *message);
#if PHP_VERSION_ID >= 50400
-void xdebug_dbgp_stream_output(php_output_context *c TSRMLS_DC);
+int xdebug_dbgp_stream_output(const char *string, unsigned int length TSRMLS_DC);
#endif
int xdebug_dbgp_register_eval_id(xdebug_con *context, function_stack_entry *fse);
char *xdebug_dbgp_get_revision(void);
diff --git a/xdebug_handlers.h b/xdebug_handlers.h
index 2adf1dd06..e8b9bf453 100644
--- a/xdebug_handlers.h
+++ b/xdebug_handlers.h
@@ -114,7 +114,7 @@ struct _xdebug_remote_handler {
#if PHP_VERSION_ID >= 50400
/* Output redirection */
- void (*remote_stream_output)(php_output_context *c TSRMLS_DC);
+ int (*remote_stream_output)(const char *string, unsigned int length TSRMLS_DC);
#endif
/* Eval ID registration and removal */