Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement issue #1004: Ability to halt on warning/notice.

  • Loading branch information...
commit 2c93aa440b9a2163d6f099409e28a578a61869dc 1 parent 1ce44fd
@derickr derickr authored
View
3  php_xdebug.h
@@ -55,6 +55,8 @@ extern zend_module_entry xdebug_module_entry;
#include "main/SAPI.h"
+#define XDEBUG_ALLOWED_HALT_LEVELS (E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE )
+
#if MEMORY_LIMIT
# define HAVE_PHP_MEMORY_USAGE 1
#elif PHP_VERSION_ID >= 50201
@@ -164,6 +166,7 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug)
function_stack_entry *active_fse;
unsigned int prev_memory;
char *file_link_format;
+ long halt_level;
zend_bool overload_var_dump;
void (*orig_var_dump_func)(INTERNAL_FUNCTION_PARAMETERS);
View
31 tests/bug01004-1.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test for xdebug.halt_level [1]
+--INI--
+error_level=-1
+xdebug.halt_level=0
+xdebug.default_enable=1
+--FILE--
+<?php
+ini_set('xdebug.halt_level', 0);
+strlen();
+echo "Hi!\n";
+
+ini_set('xdebug.halt_level', E_WARNING);
+strlen();
+echo "Hi!\n";
+
+?>
+--EXPECTF--
+Warning: strlen() expects exactly 1 parameter, 0 given in %sbug01004-1.php on line 3
+
+Call Stack:
+%w%f %w%d 1. {main}() %sbug01004-1.php:0
+%w%f %w%d 2. strlen() %sbug01004-1.php:3
+
+Hi!
+
+Warning: strlen() expects exactly 1 parameter, 0 given in %sbug01004-1.php on line 7
+
+Call Stack:
+%w%f %w%d 1. {main}() %sbug01004-1.php:0
+%w%f %w%d 2. strlen() %sbug01004-1.php:7
View
31 tests/bug01004-2.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test for xdebug.halt_level [2]
+--INI--
+error_level=-1
+xdebug.halt_level=0
+xdebug.default_enable=1
+--FILE--
+<?php
+ini_set('xdebug.halt_level', E_NOTICE);
+trigger_error("Testing");
+echo "Hi!\n";
+
+ini_set('xdebug.halt_level', E_USER_NOTICE | E_NOTICE);
+trigger_error("Testing");
+echo "Hi!\n";
+
+?>
+--EXPECTF--
+Notice: Testing in %sbug01004-2.php on line 3
+
+Call Stack:
+%w%f %w%d 1. {main}() %sbug01004-2.php:0
+%w%f %w%d 2. trigger_error() %sbug01004-2.php:3
+
+Hi!
+
+Notice: Testing in %sbug01004-2.php on line 7
+
+Call Stack:
+%w%f %w%d 1. {main}() %sbug01004-2.php:0
+%w%f %w%d 2. trigger_error() %sbug01004-2.php:7
View
1  xdebug.c
@@ -253,6 +253,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("xdebug.default_enable", "1", PHP_INI_ALL, OnUpdateBool, default_enable, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.extended_info", "1", PHP_INI_SYSTEM, OnUpdateBool, extended_info, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.file_link_format", "", PHP_INI_ALL, OnUpdateString, file_link_format, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_ENTRY("xdebug.halt_level", "0", PHP_INI_ALL, OnUpdateLong, halt_level, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.max_nesting_level", "100", PHP_INI_ALL, OnUpdateLong, max_nesting_level, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.overload_var_dump", "1", PHP_INI_ALL, OnUpdateBool, overload_var_dump, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.show_exception_trace", "0", PHP_INI_ALL, OnUpdateBool, show_ex_trace, zend_xdebug_globals, xdebug_globals)
View
4 xdebug_stack.c
@@ -689,6 +689,10 @@ void xdebug_error_cb(int type, const char *error_filename, const uint error_line
}
xdfree(error_type_str);
+ if (type & XG(halt_level) & XDEBUG_ALLOWED_HALT_LEVELS) {
+ type = E_USER_ERROR;
+ }
+
#if PHP_VERSION_ID < 50400
/* Bail out if we can't recover */
Please sign in to comment.
Something went wrong with that request. Please try again.