Skip to content

Commit a57b812

Browse files
authored
Merge pull request #542 from newrelic/oapi
feat(agent): use Observer API to hook into Zend Engine for PHPs 8.0+ (JIT Support) fix(agent): Lumen detection
2 parents c28f553 + 4086b6b commit a57b812

File tree

184 files changed

+18341
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+18341
-792
lines changed

agent/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ if test "$PHP_NEWRELIC" = "yes"; then
216216
php_explain_pdo_mysql.c php_extension.c php_file_get_contents.c \
217217
php_globals.c php_hash.c php_header.c php_httprequest_send.c \
218218
php_internal_instrument.c php_minit.c php_mshutdown.c php_mysql.c \
219-
php_mysqli.c php_newrelic.c php_nrini.c php_output.c php_pdo.c \
219+
php_mysqli.c php_newrelic.c php_nrini.c php_observer.c php_output.c php_pdo.c \
220220
php_pdo_mysql.c php_pdo_pgsql.c php_pgsql.c php_psr7.c php_redis.c \
221221
php_rinit.c php_rshutdown.c php_samplers.c php_stack.c \
222222
php_stacked_segment.c php_txn.c php_user_instrument.c \

agent/fw_cakephp.c

+37
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ nr_framework_classification_t nr_cakephp_special_2(
3939
* Component::initialize(). This function takes a controller as a parameter
4040
* and we look into the params array of that controller object, and pick up
4141
* the controller and action out of that array.
42+
*
43+
* CakePHP 1.x is end-of-life and no longer supported by the agent.
44+
* Cake PHP 1.x does not support PHP 8+ and this wrapper is not updated for OAPI
45+
* compatibility.
46+
*
4247
*/
4348
NR_PHP_WRAPPER(nr_cakephp_name_the_wt_pre20) {
4449
zval* arg1 = 0;
@@ -130,6 +135,17 @@ NR_PHP_WRAPPER_END
130135
* and we get the action from the params array in that object. The
131136
* controller object ($this) has a name, and that name is used (along
132137
* with the word "Controller" appended which is what the CakePHP code does).
138+
*
139+
* CakePHP 2.x is end-of-life and in maintenance mode (critical bugfixes only).
140+
* As such, functionality added in PHP 7.1+ is not well supported.
141+
*
142+
* txn naming scheme:
143+
* In this case, `nr_txn_set_path` is called after `NR_PHP_WRAPPER_CALL` with
144+
* `NR_NOT_OK_TO_OVERWRITE`
145+
* This entails that the last wrapped call gets to name the txn.
146+
* No changes required to ensure OAPI compatibility this corresponds to the
147+
* default way of calling the wrapped function in func_end.
148+
*
133149
*/
134150
NR_PHP_WRAPPER(nr_cakephp_name_the_wt_2) {
135151
zval* arg1 = 0;
@@ -243,6 +259,11 @@ NR_PHP_WRAPPER_END
243259
*
244260
* Dispatch::cakeError will be called if there is a problem during dispatch
245261
* (action or controller not found).
262+
*
263+
* CakePHP 1.x is end-of-life and no longer supported by the agent.
264+
* Cake PHP 1.x does not support PHP 8+ and this wrapper is not updated for OAPI
265+
* compatibility.
266+
*
246267
*/
247268
NR_PHP_WRAPPER(nr_cakephp_problem_1) {
248269
const char* name = "Dispatcher::cakeError";
@@ -266,6 +287,16 @@ NR_PHP_WRAPPER_END
266287
* appropriate Exception will be created and thrown. We wrap the CakeException
267288
* constructor instead of the Exception handler, since CakePHP allows for the
268289
* handler to be completely replaced.
290+
*
291+
* CakePHP 2.x is end-of-life and in maintenance mode (critical bugfixes only).
292+
* As such, functionality added in PHP 7.1+ is not well supported.
293+
*
294+
* txn naming scheme:
295+
* In this case, `nr_txn_set_path` is called before `NR_PHP_WRAPPER_CALL` with
296+
* `NR_NOT_OK_TO_OVERWRITE` and as this corresponds to calling the wrapped
297+
* function in func_begin it needs to be explicitly set as a before_callback to
298+
* ensure OAPI compatibility. This entails that the first wrapped call gets to
299+
* name the txn.
269300
*/
270301
NR_PHP_WRAPPER(nr_cakephp_problem_2) {
271302
const char* name = "Exception";
@@ -298,6 +329,12 @@ void nr_cakephp_enable_1(TSRMLS_D) {
298329
void nr_cakephp_enable_2(TSRMLS_D) {
299330
nr_php_wrap_user_function(NR_PSTR("Controller::invokeAction"),
300331
nr_cakephp_name_the_wt_2 TSRMLS_CC);
332+
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
333+
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
334+
nr_php_wrap_user_function_before_after_clean(
335+
NR_PSTR("CakeException::__construct"), nr_cakephp_problem_2, NULL, NULL);
336+
#else
301337
nr_php_wrap_user_function(NR_PSTR("CakeException::__construct"),
302338
nr_cakephp_problem_2 TSRMLS_CC);
339+
#endif
303340
}

0 commit comments

Comments
 (0)