@@ -58,10 +58,30 @@ void nr_php_api_add_supportability_metric(const char* name TSRMLS_DC) {
58
58
59
59
/*
60
60
* Purpose : (New Relic API) Pretend that there is an error at this exact spot.
61
- * Useful for business logic errors. newrelic_notice_error($errstr)
61
+ * Useful for business logic errors.
62
+ * - newrelic_notice_error($errstr)
63
+ * - $errstr : string : The error message to record
62
64
* - newrelic_notice_error($exception)
65
+ * - $exception : object : The exception to use to record the exception
66
+ * NOTE: This version is compatible with being a callback for set_exception_handler()
63
67
* - newrelic_notice_error($errstr,$exception)
68
+ * - $errstr : string : The error message to record
69
+ * - $exception : object : The exception to use to record the exception
70
+ * NOTE: The $errstr value is ignored! Started with agent version 4.23
71
+ * - newrelic_notice_error($errno,$errstr,$fname,$line_nr)
72
+ * - $errno : int : The error number
73
+ * - $errstr : string : The error message
74
+ * - $fname : string : The filename where the error occurred
75
+ * - $line_nr : int : The line number where the error occurred
76
+ * NOTE: This version is compatible with being a callback for set_error_handler() for PHP 8+
64
77
* - newrelic_notice_error($errno,$errstr,$fname,$line_nr,$ctx)
78
+ * - $errno : int : The error number
79
+ * - $errstr : string : The error message
80
+ * - $fname : string : The filename where the error occurred
81
+ * - $line_nr : int : The line number where the error occurred
82
+ * - $ctx : array : The context of the error
83
+ * NOTE: This version is compatible with being a callback for set_error_handler() for PHP < 8
84
+ * The $ctx is ignored!
65
85
*/
66
86
#ifdef TAGS
67
87
void zif_newrelic_notice_error (void ); /* ctags landing pad only */
@@ -141,10 +161,15 @@ PHP_FUNCTION(newrelic_notice_error) {
141
161
}
142
162
break ;
143
163
164
+ case 4 :
144
165
case 5 :
166
+ /* PHP 8+ will only pass the first 4 parameters so the 5th parameter is
167
+ * declared to be optional. Also this parameter is completely ignored
168
+ * so it doesn't matter if it is passed or not.
169
+ */
145
170
if (FAILURE
146
171
== zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET ,
147
- ZEND_NUM_ARGS () TSRMLS_CC , "lsslz !" ,
172
+ ZEND_NUM_ARGS () TSRMLS_CC , "lssl|z !" ,
148
173
& ignore1 , & errormsgstr , & errormsglen ,
149
174
& ignore2 , & ignore3 , & ignore4 , & ignore5 )) {
150
175
nrl_debug (NRL_API , "newrelic_notice_error: invalid five arguments" );
@@ -153,7 +178,7 @@ PHP_FUNCTION(newrelic_notice_error) {
153
178
break ;
154
179
155
180
default :
156
- nrl_debug (NRL_API , "newrelic_notice_error: invalid number of arguments" );
181
+ nrl_debug (NRL_API , "newrelic_notice_error: invalid number of arguments: %d" , ZEND_NUM_ARGS () );
157
182
RETURN_NULL ();
158
183
}
159
184
0 commit comments