Skip to content

Commit a333a7d

Browse files
authored
chore(agent): remove obsolete code (17/17) (#1088)
This PR removes the `PHP7` macro and the remaining uses of it in the agent codebase.
1 parent f12e255 commit a333a7d

38 files changed

+4
-241
lines changed

agent/php_agent.c

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -334,120 +334,6 @@ zend_execute_data* nr_get_zend_execute_data(NR_EXECUTE_PROTO TSRMLS_DC) {
334334
#endif
335335
}
336336

337-
/*
338-
* Purpose : Return a pointer to the arguments for the true frame that is
339-
* legitimate_frame_delta frames down from the top.
340-
*
341-
* Params : 1. The number of true frames to walk down. 0 means "top of stack".
342-
* The PHP5.5 half-formed stack top frame (with a null arguments
343-
* block) is ignored.
344-
*
345-
* 2. The execution context supplied by the zend engine; this changes
346-
* from PHP5.4 to PHP5.5, hence the use of macros.
347-
*
348-
* See this web page discussion migrating from 5.4 to 5.5 (July 22, 2013)
349-
* http://www.php.net/manual/en/migration55.internals.php
350-
*
351-
* If the arguments pointer is null, it represents either a half-formed frame
352-
* (or the base of the call stack). Go up one frame, and use the arguments
353-
* vector from there. The two functions appear to be identical.
354-
*
355-
* For PHP 5.4 (and presumably earlier), this additional stack frame isn't
356-
* there.
357-
*
358-
* See the picture near line 1525 of PHP 5.5.3 zend_execute.c
359-
*/
360-
#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO && !defined(PHP7) \
361-
&& !defined(PHP8) /* PHP 5.5 and 5.6 */
362-
static void** nr_php_get_php55_stack_arguments(int legitimate_frame_delta,
363-
NR_EXECUTE_PROTO TSRMLS_DC) {
364-
zend_execute_data* ex;
365-
void** arguments;
366-
int i;
367-
368-
ex = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
369-
370-
arguments = ex->function_state.arguments;
371-
if (NULL == arguments) {
372-
ex = ex->prev_execute_data; /* discard top partially formed frame */
373-
}
374-
375-
if (NULL == ex) {
376-
return NULL;
377-
}
378-
379-
arguments = ex->function_state.arguments;
380-
if (NULL == arguments) {
381-
return NULL; /* PHP stack appears to be be malformed */
382-
}
383-
384-
for (i = 0; i < legitimate_frame_delta; i++) {
385-
ex = ex->prev_execute_data;
386-
if (NULL == ex) {
387-
return NULL; /* No caller; we're at the bottom of the stack */
388-
}
389-
arguments = ex->function_state.arguments;
390-
if (NULL == arguments) {
391-
return NULL; /* PHP stack appears to be be malformed */
392-
}
393-
}
394-
395-
return arguments;
396-
}
397-
#endif
398-
399-
#if !defined(PHP7) && !defined(PHP8) /* PHP 5.5 and 5.6 */
400-
/*
401-
* Use detailed zend specific knowledge of the interpreter stack
402-
* to read the argument vector.
403-
* Here, the 'h' suffix means "hackery".
404-
*/
405-
static zval* nr_php_get_user_func_arg_via_h(int requested_arg_index,
406-
int* arg_count_p,
407-
NR_EXECUTE_PROTO TSRMLS_DC) {
408-
void** p = 0;
409-
zval** argp = 0;
410-
zval* arg = 0;
411-
412-
NR_UNUSED_SPECIALFN;
413-
414-
if (NULL == arg_count_p) {
415-
return NULL;
416-
}
417-
*arg_count_p = -1;
418-
if (NULL == nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC)) {
419-
return NULL;
420-
}
421-
422-
#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO
423-
p = nr_php_get_php55_stack_arguments(0, NR_EXECUTE_ORIG_ARGS TSRMLS_CC);
424-
if (NULL == p) {
425-
return NULL;
426-
}
427-
*arg_count_p = (int)(zend_uintptr_t)*p;
428-
#else
429-
p = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC)
430-
->function_state.arguments;
431-
if (NULL == p) {
432-
return NULL;
433-
}
434-
*arg_count_p = (int)(zend_uintptr_t)*p;
435-
#endif /* PHP >= 5.5 */
436-
437-
if (requested_arg_index > *arg_count_p) {
438-
return NULL;
439-
}
440-
441-
argp = ((zval**)p) - *arg_count_p + requested_arg_index - 1;
442-
if (NULL == argp) {
443-
return NULL;
444-
}
445-
446-
arg = *argp;
447-
return arg;
448-
}
449-
#endif /* !PHP7 && !PHP8*/
450-
451337
/*
452338
* NOTICE: requested_arg_index is a 1-based value, not a 0-based value!
453339
*/

agent/php_compat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#endif /* PHP 8.0+ */
1212

1313
#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
14-
#define PHP7
1514

1615
typedef uint32_t zend_uint;
1716
typedef size_t nr_string_len_t;

agent/php_newrelic.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ extern zend_module_entry newrelic_module_entry;
141141
/*
142142
* Convenience macro to handle unused TSRM parameters.
143143
*/
144-
#if ZTS && !defined(PHP7) && !defined(PHP8)
145-
#define NR_UNUSED_TSRMLS (void)tsrm_ls;
146-
#else
147144
#define NR_UNUSED_TSRMLS
148-
#endif
149145

150146
typedef enum {
151147
NR_FW_UNSET = 0,

agent/tests/test_agent.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,6 @@ static void test_nr_php_zend_function_lineno() {
592592
#endif /* PHP 7+ */
593593

594594
void test_main(void* p NRUNUSED) {
595-
#if defined(ZTS) && !defined(PHP7)
596-
void*** tsrm_ls = NULL;
597-
#endif /* ZTS && !PHP7 */
598595

599596
tlib_php_engine_create("" PTSRMLS_CC);
600597

agent/tests/test_api_datastore.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ static void test_validate(TSRMLS_D) {
131131
}
132132

133133
void test_main(void* p NRUNUSED) {
134-
#if defined(ZTS) && !defined(PHP7)
135-
void*** tsrm_ls = NULL;
136-
#endif /* ZTS && !PHP7 */
137134

138135
tlib_php_engine_create("" PTSRMLS_CC);
139136

agent/tests/test_api_distributed_trace.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ static void test_accept_distributed_trace_payload() {
3535
}
3636

3737
void test_main(void* p NRUNUSED) {
38-
#if defined(ZTS) && !defined(PHP7)
39-
void*** tsrm_ls = NULL;
40-
#endif /* ZTS && !PHP7 */
4138

4239
tlib_php_engine_create("" PTSRMLS_CC);
4340

agent/tests/test_api_internal.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ static void test_segments(TSRMLS_D) {
150150
}
151151

152152
void test_main(void* p NRUNUSED) {
153-
#if defined(ZTS) && !defined(PHP7)
154-
void*** tsrm_ls = NULL;
155-
#endif /* ZTS && !PHP7 */
156153

157154
tlib_php_engine_create("" PTSRMLS_CC);
158155

agent/tests/test_api_metadata_dt_disabled.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ static void test_get_trace_metadata_when_dt_disabled(TSRMLS_D) {
8686
}
8787

8888
void test_main(void* p NRUNUSED) {
89-
#if defined(ZTS) && !defined(PHP7)
90-
void*** tsrm_ls = NULL;
91-
#endif /* ZTS && !PHP7 */
9289

9390
tlib_php_engine_create(
9491
"newrelic.distributed_tracing_enabled = false\n" PTSRMLS_CC);

agent/tests/test_api_metadata_dt_enabled.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ static void test_get_trace_metadata_when_dt_enabled(TSRMLS_D) {
8888
}
8989

9090
void test_main(void* p NRUNUSED) {
91-
#if defined(ZTS) && !defined(PHP7)
92-
void*** tsrm_ls = NULL;
93-
#endif /* ZTS && !PHP7 */
9491

9592

9693
tlib_php_engine_create("newrelic.distributed_tracing_enabled = true\n" PTSRMLS_CC);

agent/tests/test_call.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ static void test_callable(TSRMLS_D) {
164164
}
165165

166166
void test_main(void* p NRUNUSED) {
167-
#if defined(ZTS) && !defined(PHP7)
168-
void*** tsrm_ls = NULL;
169-
#endif /* ZTS && !PHP7 */
170167

171168
tlib_php_engine_create("" PTSRMLS_CC);
172169

0 commit comments

Comments
 (0)