From: Marcus Boerger Date: Sun, 25 Jul 2004 07:05:48 +0000 (+0000) Subject: - Add optional parameters $filename and $lineno to ErrorException X-Git-Tag: PRE_ZEND_VM_DISPATCH_PATCH~382 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b9c90efd3bad80077e365ab2bfa28dc9b45c969;p=php - Add optional parameters $filename and $lineno to ErrorException constructor to allow overwriting automatically retrieved information. # It may be reasonable to delete the trace in case that feature is used. --- diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 8d218f722c..0ceba5fc84 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -147,16 +147,16 @@ ZEND_METHOD(exception, __construct) /* }}} */ -/* {{{ proto ErrorException::__construct(string message, int code, int severity) +/* {{{ proto ErrorException::__construct(string message, int code, int severity [, $filename [, $lineno]]) ErrorException constructor */ ZEND_METHOD(error_exception, __construct) { - char *message = NULL; - long code = 0, severity = E_ERROR; + char *message = NULL, *filename = NULL; + long code = 0, severity = E_ERROR, lineno; zval *object; - int argc = ZEND_NUM_ARGS(), message_len; + int argc = ZEND_NUM_ARGS(), message_len, filename_len; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sll", &message, &message_len, &code, &severity) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|sllsl", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno) == FAILURE) { zend_error(E_CORE_ERROR, "Wrong parameter count for exception([string $exception [, long $code ]])"); } @@ -171,6 +171,14 @@ ZEND_METHOD(error_exception, __construct) } zend_update_property_long(default_exception_ce, object, "severity", sizeof("severity")-1, severity TSRMLS_CC); + + if (argc >= 4) { + zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC); + if (argc < 5) { + lineno = 0; // invalidate lineno + } + zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); + } } /* }}} */ @@ -532,10 +540,12 @@ static zend_function_entry default_exception_functions[] = { }; static -ZEND_BEGIN_ARG_INFO(arginfo_error_exception___construct, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_error_exception___construct, 0, 0, 3) ZEND_ARG_INFO(0, message) ZEND_ARG_INFO(0, code) ZEND_ARG_INFO(0, severity) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, lineno) ZEND_END_ARG_INFO(); static zend_function_entry error_exception_functions[] = {