Skip to content

Commit 8537742

Browse files
committed
fix guzzle
1 parent 0aa9c77 commit 8537742

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

agent/lib_guzzle4.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,33 @@ const zend_function_entry nr_guzzle4_subscriber_functions[]
436436
* Purpose : Registers an event subscriber for a newly instantiated
437437
* GuzzleHttp\Client object.
438438
*/
439+
440+
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
441+
void nr_guzzle4_client_construct(NR_EXECUTE_PROTO) {
442+
#else
439443
NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) {
444+
#endif
440445
zval* emitter = NULL;
441446
zval* retval = NULL;
442447
zval* subscriber = NULL;
443448
zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
444449

450+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
445451
(void)wraprec;
452+
#endif
446453
NR_UNUSED_SPECIALFN;
447454

448455
/* This is how we distinguish Guzzle 4/5 from other versions. */
449456
if (0 == nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) {
457+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
450458
NR_PHP_WRAPPER_CALL;
459+
#endif
451460
goto end;
452461
}
453462

463+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
454464
NR_PHP_WRAPPER_CALL;
465+
#endif
455466

456467
/*
457468
* We can't have newrelic\Guzzle4\Subscriber implement
@@ -503,7 +514,9 @@ NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) {
503514
nr_php_zval_free(&emitter);
504515
nr_php_zval_free(&subscriber);
505516
}
517+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
506518
NR_PHP_WRAPPER_END
519+
#endif
507520

508521
void nr_guzzle4_enable(TSRMLS_D) {
509522
if (0 == NRINI(guzzle_enabled)) {

agent/lib_guzzle4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ extern void nr_guzzle4_rshutdown(TSRMLS_D);
2626
/*
2727
* Purpose : Client::__construct() wrapper for Guzzle 4.
2828
*/
29+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
2930
extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle4_client_construct);
31+
#else
32+
extern void nr_guzzle4_client_construct(NR_EXECUTE_PROTO);
33+
#endif
3034

3135
#endif /* LIB_GUZZLE4_HDR */

agent/lib_guzzle6.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ const zend_function_entry nr_guzzle6_requesthandler_functions[]
342342

343343
/* }}} */
344344

345+
#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO
346+
void nr_guzzle6_client_construct(NR_EXECUTE_PROTO) {
347+
#else
345348
NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) {
349+
#endif
346350
zval* config;
347351
zend_class_entry* guzzle_client_ce;
348352
zval* handler_stack;
@@ -357,16 +361,22 @@ NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) {
357361
nr_free(version);
358362
}
359363

364+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
360365
(void)wraprec;
366+
#endif
361367
NR_UNUSED_SPECIALFN;
362368

363369
/* This is how we distinguish Guzzle 4/5. */
364370
if (nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) {
371+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
365372
NR_PHP_WRAPPER_CALL;
373+
#endif
366374
goto end;
367375
}
368376

377+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
369378
NR_PHP_WRAPPER_CALL;
379+
#endif
370380

371381
/*
372382
* Get our middleware callable (which is just a string), and make sure it's
@@ -413,7 +423,9 @@ NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) {
413423
nr_php_zval_free(&middleware);
414424
nr_php_scope_release(&this_var);
415425
}
426+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
416427
NR_PHP_WRAPPER_END
428+
#endif
417429

418430
void nr_guzzle6_enable(TSRMLS_D) {
419431
int retval;

agent/lib_guzzle6.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ extern void nr_guzzle6_minit(TSRMLS_D);
2020
/*
2121
* Purpose : Client::__construct() wrapper for Guzzle 6.
2222
*/
23+
#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO
2324
extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle6_client_construct);
25+
#else
26+
extern void nr_guzzle6_client_construct(NR_EXECUTE_PROTO);
27+
#endif
2428

2529
#endif /* LIB_GUZZLE4_HDR */

agent/php_wrapper.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
277277
const nrtxn_t* txn = NRPRG(txn); \
278278
const nrtime_t txn_start_time = nr_txn_start_time(txn); \
279279
if (NRPRG(in_wrapper)) { \
280-
printf("AAHHHHHHHHHHH\n"); \
280+
printf("AAHHHHHHHHHHH %s\n", #name); \
281281
} \
282282
NRPRG(in_wrapper) = true; \
283283
\
@@ -384,10 +384,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D);
384384
}
385385
#else
386386
#define NR_PHP_WRAPPER_DELEGATE(name) \
387-
if (!was_executed) { \
388-
((name)(execute_data)); \
389-
was_executed = 1; \
390-
}
387+
((name)(execute_data, func_return_value));
391388
#endif
392389

393390
static inline bool is_instrumentation_set_and_not_equal(

0 commit comments

Comments
 (0)