Skip to content

Commit ddc5230

Browse files
authored
Merge pull request #898 from newrelic/dev
Release 10.21
2 parents ca8f7ff + 42136bb commit ddc5230

34 files changed

+1834
-114
lines changed

.github/workflows/code-coverage-baseline.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
5656
$IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon_test
5757
- name: Save integration_runner for integration tests
58-
uses: actions/upload-artifact@v3
58+
uses: actions/upload-artifact@v4
5959
with:
6060
name: integration_runner-${{matrix.platform}}-${{matrix.arch}}
6161
path: php-agent/bin/integration_runner
@@ -124,19 +124,19 @@ jobs:
124124
-e ENABLE_COVERAGE=${{matrix.codecov}}
125125
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-check
126126
- name: Save newrelic.so for integration tests
127-
uses: actions/upload-artifact@v3
127+
uses: actions/upload-artifact@v4
128128
with:
129129
name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
130130
path: php-agent/agent/modules/newrelic.so
131131
- name: Save axiom gcov data files (*.gcno, *.gcna)
132132
if: ${{ matrix.codecov == 1 }}
133-
uses: actions/upload-artifact@v3
133+
uses: actions/upload-artifact@v4
134134
with:
135135
name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
136136
path: php-agent/axiom/*.gc*
137137
- name: Save agent gcov data files (*.gcno, *.gcna)
138138
if: ${{ matrix.codecov == 1 }}
139-
uses: actions/upload-artifact@v3
139+
uses: actions/upload-artifact@v4
140140
with:
141141
name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
142142
path: php-agent/agent/.libs/*.gc*
@@ -161,24 +161,24 @@ jobs:
161161
repository: ${{ inputs.origin }}/newrelic-php-agent
162162
ref: ${{ inputs.ref }}
163163
- name: Get integration_runner
164-
uses: actions/download-artifact@v3
164+
uses: actions/download-artifact@v4
165165
with:
166166
name: integration_runner-${{matrix.platform}}-${{matrix.arch}}
167167
path: php-agent/bin
168168
- name: Get newrelic.so
169-
uses: actions/download-artifact@v3
169+
uses: actions/download-artifact@v4
170170
with:
171171
name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
172172
path: php-agent/agent/modules
173173
- name: Get axiom gcov data files
174174
if: ${{ matrix.codecov == 1 }}
175-
uses: actions/download-artifact@v3
175+
uses: actions/download-artifact@v4
176176
with:
177177
name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
178178
path: php-agent/axiom
179179
- name: Get agent gcov data files
180180
if: ${{ matrix.codecov == 1 }}
181-
uses: actions/download-artifact@v3
181+
uses: actions/download-artifact@v4
182182
with:
183183
name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
184184
path: php-agent/agent/.libs

.github/workflows/codeql.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,20 @@ jobs:
4141
uses: github/codeql-action/init@v3
4242
with:
4343
languages: ${{ matrix.language }}
44+
build-mode: manual
4445
# If you wish to specify custom queries, you can do so here or in a config file.
4546
# By default, queries listed here will override any specified in a config file.
4647
# Prefix the list here with "+" to use these queries and those in the config file.
4748

4849
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
4950
# queries: security-extended,security-and-quality
5051

51-
52-
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
53-
# If this step fails, then you should remove it and run the build manually (see below)
54-
- name: Autobuild
55-
uses: github/codeql-action/autobuild@v3
56-
5752
# ℹ️ Command-line programs to run using the OS shell.
5853
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
5954

60-
# If the Autobuild fails above, remove it and uncomment the following three lines.
61-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
62-
63-
# - run: |
64-
# echo "Run, Build Application using script"
65-
# ./location_of_script_within_repo/buildscript.sh
55+
- name: Build
56+
run: |
57+
make ${{ matrix.language == 'go' && 'daemon' || 'agent' }}
6658
6759
- name: Perform CodeQL Analysis
6860
uses: github/codeql-action/analyze@v3

.github/workflows/make-agent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
6363
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent
6464
- name: Save newrelic.so for integration tests
65-
uses: actions/upload-artifact@v3
65+
uses: actions/upload-artifact@v4
6666
with:
6767
name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}}
6868
path: php-agent/agent/modules/newrelic.so

.github/workflows/make-for-platform-on-arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
-e APP_supportability=${{secrets.APP_SUPPORTABILITY}}
7979
$IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION ${{inputs.make-target}}
8080
- name: Save ${{inputs.make-target}} artifact
81-
uses: actions/upload-artifact@v3
81+
uses: actions/upload-artifact@v4
8282
with:
8383
name: ${{inputs.artifact-name}}-${{matrix.platform}}-${{inputs.arch}}
8484
path: php-agent/${{ inputs.artifact-pattern }}

.github/workflows/make-integration-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ jobs:
4343
repository: ${{ inputs.origin }}/newrelic-php-agent
4444
ref: ${{ inputs.ref }}
4545
- name: Get integration_runner
46-
uses: actions/download-artifact@v3
46+
uses: actions/download-artifact@v4
4747
with:
4848
name: integration_runner-${{matrix.platform}}-${{inputs.arch}}
4949
path: php-agent/bin
5050
- name: Get newrelic.so
51-
uses: actions/download-artifact@v3
51+
uses: actions/download-artifact@v4
5252
with:
5353
name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}}
5454
path: php-agent/agent/modules

.github/workflows/release-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ jobs:
5252
-e BUILD_NUMBER=${{inputs.build-number}}
5353
$IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION release-daemon
5454
- name: Save build artifacts
55-
uses: actions/upload-artifact@v3
55+
uses: actions/upload-artifact@v4
5656
with:
5757
path: newrelic-php-agent/releases
58-
name: release-from-gha
58+
name: release-from-gha-${{ matrix.platform }}-${{ matrix.arch }}
5959
if-no-files-found: error
6060
agent_release:
6161
env:
@@ -87,8 +87,8 @@ jobs:
8787
-e BUILD_NUMBER=${{inputs.build-number}}
8888
$IMAGE_NAME:agent-builder-php${{matrix.php_ver}}-${{matrix.platform}}-$IMAGE_VERSION release-${{matrix.php_ver}}-gha
8989
- name: Save build artifacts
90-
uses: actions/upload-artifact@v3
90+
uses: actions/upload-artifact@v4
9191
with:
9292
path: newrelic-php-agent/releases
93-
name: release-from-gha
93+
name: release-from-gha-${{ matrix.platform }}-${{ matrix.arch }}
9494
if-no-files-found: error

.github/workflows/test-agent.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
-v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent"
5959
$IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon_test
6060
- name: Save integration_runner for integration tests
61-
uses: actions/upload-artifact@v3
61+
uses: actions/upload-artifact@v4
6262
with:
6363
name: integration_runner-${{matrix.platform}}-${{matrix.arch}}
6464
path: php-agent/bin/integration_runner
@@ -159,19 +159,19 @@ jobs:
159159
-e ENABLE_COVERAGE=${{matrix.codecov}}
160160
$IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }}
161161
- name: Save newrelic.so for integration tests
162-
uses: actions/upload-artifact@v3
162+
uses: actions/upload-artifact@v4
163163
with:
164164
name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
165165
path: php-agent/agent/modules/newrelic.so
166166
- name: Save axiom gcov data files (*.gcno, *.gcna)
167167
if: ${{ matrix.codecov == 1 }}
168-
uses: actions/upload-artifact@v3
168+
uses: actions/upload-artifact@v4
169169
with:
170170
name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
171171
path: php-agent/axiom/*.gc*
172172
- name: Save agent gcov data files (*.gcno, *.gcna)
173173
if: ${{ matrix.codecov == 1 }}
174-
uses: actions/upload-artifact@v3
174+
uses: actions/upload-artifact@v4
175175
with:
176176
name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
177177
path: php-agent/agent/.libs/*.gc*
@@ -206,24 +206,24 @@ jobs:
206206
with:
207207
path: php-agent
208208
- name: Get integration_runner
209-
uses: actions/download-artifact@v3
209+
uses: actions/download-artifact@v4
210210
with:
211211
name: integration_runner-${{matrix.platform}}-${{matrix.arch}}
212212
path: php-agent/bin
213213
- name: Get newrelic.so
214-
uses: actions/download-artifact@v3
214+
uses: actions/download-artifact@v4
215215
with:
216216
name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
217217
path: php-agent/agent/modules
218218
- name: Get axiom gcov data files
219219
if: ${{ matrix.codecov == 1 }}
220-
uses: actions/download-artifact@v3
220+
uses: actions/download-artifact@v4
221221
with:
222222
name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
223223
path: php-agent/axiom
224224
- name: Get agent gcov data files
225225
if: ${{ matrix.codecov == 1 }}
226-
uses: actions/download-artifact@v3
226+
uses: actions/download-artifact@v4
227227
with:
228228
name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}}
229229
path: php-agent/agent/.libs

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.20.0
1+
10.21.0

agent/lib_guzzle6.c

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,13 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler,
112112
nr_segment_external_params_t external_params = {.library = "Guzzle 6"};
113113
zval* request;
114114
zval* method;
115-
zval* status;
115+
zval* status = NULL;
116116

117117
if (NR_FAILURE
118118
== nr_guzzle_obj_find_and_remove(handler, &segment TSRMLS_CC)) {
119119
return;
120120
}
121121

122-
if (!nr_php_psr7_is_response(response TSRMLS_CC)) {
123-
return;
124-
}
125-
126122
request = nr_guzzle6_requesthandler_get_request(handler TSRMLS_CC);
127123
if (NULL == request) {
128124
return;
@@ -133,32 +129,34 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler,
133129
return;
134130
}
135131

136-
/*
137-
* Get the X-NewRelic-App-Data response header. If there isn't one, NULL is
138-
* returned, and everything still works just fine.
139-
*/
140-
external_params.encoded_response_header
141-
= nr_php_psr7_message_get_header(response, X_NEWRELIC_APP_DATA TSRMLS_CC);
142-
143-
if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) {
144-
nrl_verbosedebug(
145-
NRL_CAT, "CAT: outbound response: transport='Guzzle 6' %s=" NRP_FMT,
146-
X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header));
147-
}
148-
149-
status = nr_php_call(response, "getStatusCode");
150-
151-
if (nr_php_is_zval_valid_integer(status)) {
152-
external_params.status = Z_LVAL_P(status);
153-
}
154-
155132
method = nr_php_call(request, "getMethod");
156133

157134
if (nr_php_is_zval_valid_string(method)) {
158135
external_params.procedure
159136
= nr_strndup(Z_STRVAL_P(method), Z_STRLEN_P(method));
160137
}
161138

139+
if (NULL != response && nr_php_psr7_is_response(response TSRMLS_CC)) {
140+
/*
141+
* Get the X-NewRelic-App-Data response header. If there isn't one, NULL is
142+
* returned, and everything still works just fine.
143+
*/
144+
external_params.encoded_response_header
145+
= nr_php_psr7_message_get_header(response, X_NEWRELIC_APP_DATA TSRMLS_CC);
146+
147+
if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) {
148+
nrl_verbosedebug(
149+
NRL_CAT, "CAT: outbound response: transport='Guzzle 6' %s=" NRP_FMT,
150+
X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header));
151+
}
152+
153+
status = nr_php_call(response, "getStatusCode");
154+
155+
if (nr_php_is_zval_valid_integer(status)) {
156+
external_params.status = Z_LVAL_P(status);
157+
}
158+
}
159+
162160
nr_segment_external_end(&segment, &external_params);
163161

164162
nr_free(external_params.encoded_response_header);
@@ -291,6 +289,12 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) {
291289
return;
292290
}
293291

292+
this_obj = NR_PHP_USER_FN_THIS();
293+
if (NULL == this_obj) {
294+
nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot obtain 'this'", __func__);
295+
return;
296+
}
297+
294298
/*
295299
* See if this is an exception that we can get a response from. We're going
296300
* to look for BadResponseException because, although it inherits from
@@ -305,6 +309,7 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) {
305309
*/
306310
if (!nr_php_object_instanceof_class(
307311
exc, "GuzzleHttp\\Exception\\BadResponseException" TSRMLS_CC)) {
312+
nr_guzzle6_requesthandler_handle_response(this_obj, NULL);
308313
return;
309314
}
310315

@@ -314,12 +319,6 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) {
314319
return;
315320
}
316321

317-
this_obj = NR_PHP_USER_FN_THIS();
318-
if (NULL == this_obj) {
319-
nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot obtain 'this'", __func__);
320-
return;
321-
}
322-
323322
nr_guzzle6_requesthandler_handle_response(this_obj, response TSRMLS_CC);
324323

325324
nr_php_zval_free(&response);
@@ -448,6 +447,7 @@ void nr_guzzle6_enable(TSRMLS_D) {
448447
"namespace newrelic\\Guzzle6;"
449448

450449
"use Psr\\Http\\Message\\RequestInterface;"
450+
"use GuzzleHttp\\Promise\\PromiseInterface;"
451451

452452
"if (!function_exists('newrelic\\Guzzle6\\middleware')) {"
453453
" function middleware(callable $handler) {"
@@ -468,8 +468,16 @@ void nr_guzzle6_enable(TSRMLS_D) {
468468
*/
469469
" $rh = new RequestHandler($request);"
470470
" $promise = $handler($request, $options);"
471-
" $promise->then([$rh, 'onFulfilled'], [$rh, 'onRejected']);"
472-
471+
" if (PromiseInterface::REJECTED == $promise->getState()) {"
472+
/*
473+
Special case for sync request. When sync requests is rejected,
474+
onRejected callback is not called via `PromiseInterface::then`
475+
and needs to be called manually.
476+
*/
477+
" $rh->onRejected($promise);"
478+
" } else {"
479+
" $promise->then([$rh, 'onFulfilled'], [$rh, 'onRejected']);"
480+
" }"
473481
" return $promise;"
474482
" };"
475483
" }"

agent/php_execute.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,9 +2163,6 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) {
21632163
int show_executes = NR_PHP_PROCESS_GLOBALS(special_flags).show_executes;
21642164

21652165
if (nrunlikely(show_executes)) {
2166-
nrl_verbosedebug(NRL_AGENT,
2167-
"Stack depth: %d after OAPI function beginning via %s",
2168-
NRPRG(php_cur_stack_depth), __func__);
21692166
nr_php_show_exec(NR_EXECUTE_ORIG_ARGS);
21702167
}
21712168
nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS);
@@ -2191,9 +2188,6 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data,
21912188
= NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_returns;
21922189

21932190
if (nrunlikely(show_executes_return)) {
2194-
nrl_verbosedebug(NRL_AGENT,
2195-
"Stack depth: %d before OAPI function exiting via %s",
2196-
NRPRG(php_cur_stack_depth), __func__);
21972191
nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
21982192
}
21992193

0 commit comments

Comments
 (0)