Skip to content

Commit 5b680a1

Browse files
committed
adjust list of magic files
vendor/composer/installed.php is critical component of Composer's runtime API - methods from \Composer\InstalledVersions class do not work without it. Include this file in the mocked composer of 'happy path' tests.
1 parent bf48be9 commit 5b680a1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

agent/php_execute.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,11 @@ static void nr_execute_handle_autoload_composer(const char* filename) {
11091109
// Composer signature file"
11101110
#define COMPOSER_MAGIC_FILE_1 "composer/autoload_real.php"
11111111
#define COMPOSER_MAGIC_FILE_1_LEN (sizeof(COMPOSER_MAGIC_FILE_1) - 1)
1112-
// Composer runtime API file:
1112+
// Composer runtime API files:
11131113
#define COMPOSER_MAGIC_FILE_2 "composer/InstalledVersions.php"
11141114
#define COMPOSER_MAGIC_FILE_2_LEN (sizeof(COMPOSER_MAGIC_FILE_2) - 1)
1115+
#define COMPOSER_MAGIC_FILE_3 "composer/installed.php"
1116+
#define COMPOSER_MAGIC_FILE_3_LEN (sizeof(COMPOSER_MAGIC_FILE_3) - 1)
11151117
char* vendor_path = NULL; // result of dirname(filename)
11161118

11171119
vendor_path = nr_execute_handle_autoload_composer_get_vendor_path(filename);
@@ -1130,6 +1132,11 @@ static void nr_execute_handle_autoload_composer(const char* filename) {
11301132
return;
11311133
}
11321134

1135+
if (!nr_execute_handle_autoload_composer_file_exists(vendor_path, COMPOSER_MAGIC_FILE_3)) {
1136+
nrl_verbosedebug(NRL_FRAMEWORK, "'%s' not found in '%s'", COMPOSER_MAGIC_FILE_3, vendor_path);
1137+
return;
1138+
}
1139+
11331140
nrl_verbosedebug(NRL_FRAMEWORK, "detected composer");
11341141
NRPRG(txn)->composer_info.composer_detected = true;
11351142
nr_fw_support_add_library_supportability_metric(NRPRG(txn), "Composer");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/*
3+
* Copyright 2020 New Relic Corporation. All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*DESCRIPTION
8+
This file is needed by real Composer's runtime API, and agent verifies its presence to determine if Composer is used.
9+
Therefore, even though mocked version of Composer's runtime API does not use this file but (and that's why its empty),
10+
it still needs to be present.
11+
*/

0 commit comments

Comments
 (0)