Skip to content

Commit c4172d8

Browse files
committed
define dedicated nrframework_t for Yii2
Yii 1.x and Yii 2.x are detected as two distinct frameworks and therefore need their own values in nrframework_t enum. This helps with tracking framework usage through supportability metrics. This approach obsoletes the need to store framework_version.
1 parent f159113 commit c4172d8

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

agent/fw_yii.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ NR_PHP_WRAPPER(nr_yii1_runWithParams_wrapper) {
3737
(void)wraprec;
3838
NR_UNUSED_SPECIALFN;
3939

40-
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK_VERSION(NR_FW_YII, 1);
40+
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII1);
4141

4242
this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
4343
if (NULL == this_var) {
@@ -89,7 +89,6 @@ NR_PHP_WRAPPER_END
8989
* Enable Yii1 instrumentation.
9090
*/
9191
void nr_yii1_enable(TSRMLS_D) {
92-
NRPRG(framework_version) = 1;
9392
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
9493
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
9594
nr_php_wrap_user_function_before_after_clean(
@@ -119,7 +118,7 @@ NR_PHP_WRAPPER(nr_yii2_runWithParams_wrapper) {
119118
(void)wraprec;
120119
NR_UNUSED_SPECIALFN;
121120

122-
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK_VERSION(NR_FW_YII, 2);
121+
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII2);
123122

124123
this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
125124
if (NULL == this_var) {
@@ -161,7 +160,7 @@ NR_PHP_WRAPPER(nr_yii2_error_handler_wrapper) {
161160
NR_UNUSED_SPECIALFN;
162161
(void)wraprec;
163162

164-
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK_VERSION(NR_FW_YII, 2);
163+
NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII2);
165164

166165
exception = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
167166
if (NULL == exception || !nr_php_is_zval_valid_object(exception)) {
@@ -189,7 +188,6 @@ NR_PHP_WRAPPER_END
189188
* Enable Yii2 instrumentation.
190189
*/
191190
void nr_yii2_enable(TSRMLS_D) {
192-
NRPRG(framework_version) = 2;
193191
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
194192
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
195193
nr_php_wrap_user_function_before_after_clean(

agent/php_execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ static const nr_framework_table_t all_frameworks[] = {
416416
{"WordPress", "wordpress", NR_PSTR("wp-config.php"), 0, nr_wordpress_enable,
417417
NR_FW_WORDPRESS},
418418

419-
{"Yii", "yii", NR_PSTR("framework/yii.php"), 0, nr_yii1_enable, NR_FW_YII},
420-
{"Yii", "yii", NR_PSTR("framework/yiilite.php"), 0, nr_yii1_enable, NR_FW_YII},
421-
{"Yii2", "yii2", NR_PSTR("yii2/baseyii.php"), 0, nr_yii2_enable, NR_FW_YII},
419+
{"Yii", "yii", NR_PSTR("framework/yii.php"), 0, nr_yii1_enable, NR_FW_YII1},
420+
{"Yii", "yii", NR_PSTR("framework/yiilite.php"), 0, nr_yii1_enable, NR_FW_YII1},
421+
{"Yii2", "yii2", NR_PSTR("yii2/baseyii.php"), 0, nr_yii2_enable, NR_FW_YII2},
422422

423423
/* See above: Laminas, the successor to Zend, which shares much
424424
of the instrumentation implementation with Zend */

agent/php_newrelic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ typedef enum {
167167
NR_FW_SYMFONY2,
168168
NR_FW_SYMFONY4,
169169
NR_FW_WORDPRESS,
170-
NR_FW_YII,
170+
NR_FW_YII1,
171+
NR_FW_YII2,
171172
NR_FW_ZEND,
172173
NR_FW_ZEND2,
173174
NR_FW_LAMINAS3,

0 commit comments

Comments
 (0)