@@ -20,7 +20,6 @@ static zval* nr_php_get_zval_object_property_with_class_internal(
20
20
zval * object ,
21
21
zend_class_entry * ce ,
22
22
const char * cname TSRMLS_DC ) {
23
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
24
23
/*
25
24
* Although the below notes still apply in principle, PHP 7 additionally broke
26
25
* the API for zend_read_property by adding an rv parameter, which is used to
@@ -41,25 +40,6 @@ static zval* nr_php_get_zval_object_property_with_class_internal(
41
40
if (& EG (uninitialized_zval ) != data ) {
42
41
return data ;
43
42
}
44
- #else
45
- /*
46
- * This attempts to read uninitialized (or non existing) properties always
47
- * return uninitialized_zval_ptr, even in the case where we read a property
48
- * during pre-hook time on a constructor.
49
- */
50
- zend_bool silent = 1 ; /* forces BP_VAR_IS semantics */
51
- #if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO
52
- zval * data = zend_read_property (ce , object , cname , nr_strlen (cname ),
53
- silent TSRMLS_CC );
54
- #else
55
- zval * data = zend_read_property (ce , object , (char * )nr_remove_const (cname ),
56
- nr_strlen (cname ), silent TSRMLS_CC );
57
- #endif /* PHP >= 5.4 */
58
-
59
- if (EG (uninitialized_zval_ptr ) != data ) {
60
- return data ;
61
- }
62
- #endif /* PHP7+ */
63
43
64
44
return NULL ;
65
45
}
@@ -149,32 +129,12 @@ int nr_php_object_has_method(zval* object, const char* lcname TSRMLS_DC) {
149
129
return 0 ;
150
130
} else {
151
131
void * func ;
152
-
153
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
154
132
zend_string * name_str = zend_string_init (vname , namelen , 0 );
155
133
156
134
func = (void * )Z_OBJ_HT_P (object )-> get_method (& Z_OBJ_P (object ), name_str ,
157
135
NULL TSRMLS_CC );
158
136
159
137
zend_string_release (name_str );
160
- #elif ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO
161
- /*
162
- * This can leak if the object has a __call() method, as in that situation
163
- * only, zend_std_get_method() will indirectly allocate a new
164
- * zend_function in zend_get_user_call_function().
165
- *
166
- * We can't easily detect this, and the zend_function() is allocated via
167
- * emalloc(), so we're just going to let this slide and let the Zend
168
- * Engine clean it up at RSHUTDOWN. Note that this needs to be suppressed
169
- * in Valgrind, though.
170
- */
171
- func = (void * )Z_OBJ_HT_P (object )-> get_method (
172
- & object , vname , namelen ,
173
- NULL TSRMLS_CC ); /* nr_php_object_has_method */
174
- #else /* PHP < 5.4 */
175
- func = (void * )Z_OBJ_HT_P (object )-> get_method (
176
- & object , vname , namelen TSRMLS_CC ); /* nr_php_object_has_method */
177
- #endif
178
138
179
139
if (NULL == func ) {
180
140
return 0 ;
@@ -214,23 +174,11 @@ zend_function* nr_php_find_function(const char* name TSRMLS_DC) {
214
174
* whereas PHP 7 only uses a single level of indirection.
215
175
*/
216
176
zend_class_entry * nr_php_find_class (const char * name TSRMLS_DC ) {
217
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
218
177
if (NULL == name ) {
219
178
return NULL ;
220
179
}
221
180
222
181
return (zend_class_entry * )nr_php_zend_hash_find_ptr (EG (class_table ), name );
223
- #else
224
- zend_class_entry * * ce_ptr = 0 ;
225
-
226
- if (0 == name ) {
227
- return 0 ;
228
- }
229
-
230
- ce_ptr = (zend_class_entry * * )nr_php_zend_hash_find_ptr (EG (class_table ), name );
231
-
232
- return ce_ptr ? * ce_ptr : NULL ;
233
- #endif /* PHP7+ */
234
182
}
235
183
236
184
zend_function * nr_php_find_class_method (const zend_class_entry * klass ,
@@ -286,15 +234,9 @@ zend_function* nr_php_zval_to_function(zval* zv TSRMLS_DC) {
286
234
return NULL ;
287
235
}
288
236
289
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
290
237
if (zend_is_callable_ex (zv , NULL , 0 , NULL , & fcc , NULL )) {
291
238
return fcc .function_handler ;
292
239
}
293
- #else
294
- if (zend_is_callable_ex (zv , NULL , 0 , NULL , NULL , & fcc , NULL TSRMLS_CC )) {
295
- return fcc .function_handler ;
296
- }
297
- #endif /* PHP7+ */
298
240
299
241
return NULL ;
300
242
}
@@ -348,41 +290,20 @@ zval* nr_php_get_user_func_arg(size_t requested_arg_index,
348
290
return NULL ;
349
291
}
350
292
351
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
352
293
(void )arg_count_via_h ;
353
294
354
295
if (requested_arg_index > ZEND_CALL_NUM_ARGS (execute_data )) {
355
296
return NULL ;
356
297
}
357
298
358
299
arg_via_h = ZEND_CALL_ARG (execute_data , requested_arg_index );
359
- #else
360
- arg_via_h = nr_php_get_user_func_arg_via_h (
361
- requested_arg_index , & arg_count_via_h , NR_EXECUTE_ORIG_ARGS TSRMLS_CC );
362
- #endif /* PHP7+ */
363
300
364
301
return arg_via_h ;
365
302
}
366
303
367
304
size_t nr_php_get_user_func_arg_count (NR_EXECUTE_PROTO TSRMLS_DC ) {
368
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
369
305
NR_UNUSED_FUNC_RETURN_VALUE ;
370
306
return (size_t )ZEND_CALL_NUM_ARGS (execute_data );
371
- #else
372
- int arg_count_via_h = -1 ;
373
-
374
- if (NULL
375
- == nr_php_get_user_func_arg_via_h (1 , & arg_count_via_h ,
376
- NR_EXECUTE_ORIG_ARGS TSRMLS_CC )) {
377
- return 0 ;
378
- } else if (arg_count_via_h < 0 ) {
379
- nrl_verbosedebug (NRL_AGENT , "%s: unexpected argument count %d" , __func__ ,
380
- arg_count_via_h );
381
- return 0 ;
382
- }
383
-
384
- return (size_t )arg_count_via_h ;
385
- #endif /* PHP7+ */
386
307
}
387
308
388
309
zend_execute_data * nr_php_get_caller_execute_data (NR_EXECUTE_PROTO ,
@@ -411,30 +332,18 @@ zend_execute_data* nr_php_get_caller_execute_data(NR_EXECUTE_PROTO,
411
332
ced = ced -> prev_execute_data ;
412
333
}
413
334
414
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
415
335
if ((NULL == ced ) || (NULL == ced -> opline )) {
416
336
return NULL ;
417
337
}
418
- #else
419
- if ((NULL == ced ) || (NULL == ced -> op_array )) {
420
- return NULL ;
421
- }
422
- #endif /* PHP7+ */
423
338
424
339
if ((ZEND_DO_FCALL != ced -> opline -> opcode )
425
340
&& (ZEND_DO_FCALL_BY_NAME != ced -> opline -> opcode )) {
426
341
return NULL ;
427
342
}
428
343
429
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
430
344
if (NULL == ced -> func ) {
431
345
return NULL ;
432
346
}
433
- #else
434
- if (0 == ced -> function_state .function ) {
435
- return NULL ;
436
- }
437
- #endif /* PHP7+ */
438
347
439
348
return ced ;
440
349
}
@@ -448,17 +357,12 @@ const zend_function* nr_php_get_caller(NR_EXECUTE_PROTO,
448
357
return NULL ;
449
358
}
450
359
451
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
452
360
return ped -> func ;
453
- #else
454
- return ped -> function_state .function ;
455
- #endif /* PHP7+ */
456
361
}
457
362
458
363
zval * nr_php_get_active_php_variable (const char * name TSRMLS_DC ) {
459
364
HashTable * table ;
460
365
461
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
462
366
table = zend_rebuild_symbol_table ();
463
367
464
368
/*
@@ -472,10 +376,6 @@ zval* nr_php_get_active_php_variable(const char* name TSRMLS_DC) {
472
376
* https://nikic.github.io/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html#indirect-zvals
473
377
*/
474
378
return nr_php_zval_direct (nr_php_zend_hash_find (table , name ));
475
- #else
476
- table = EG (active_symbol_table );
477
- return nr_php_zend_hash_find (table , name );
478
- #endif /* PHP7+ */
479
379
}
480
380
481
381
int nr_php_silence_errors (TSRMLS_D ) {
@@ -491,7 +391,6 @@ void nr_php_restore_errors(int error_reporting TSRMLS_DC) {
491
391
}
492
392
493
393
zval * nr_php_get_constant (const char * name TSRMLS_DC ) {
494
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
495
394
zval * constant ;
496
395
zval * copy = NULL ;
497
396
zend_string * name_str ;
@@ -515,31 +414,9 @@ zval* nr_php_get_constant(const char* name TSRMLS_DC) {
515
414
ZVAL_DUP (copy , constant );
516
415
517
416
return copy ;
518
- #else
519
- nr_string_len_t len ;
520
- int rv ;
521
- zval * constant = NULL ;
522
-
523
- if (NULL == name ) {
524
- return NULL ;
525
- }
526
-
527
- len = nr_strlen (name );
528
- constant = nr_php_zval_alloc ();
529
-
530
- /* zend_get_constant returns 0 and 1 (not SUCCESS or FAILURE) */
531
- rv = zend_get_constant (name , len , constant TSRMLS_CC );
532
- if (0 == rv ) {
533
- nr_php_zval_free (& constant );
534
- return NULL ;
535
- }
536
-
537
- return constant ;
538
- #endif /* PHP7+ */
539
417
}
540
418
541
419
zval * nr_php_get_class_constant (const zend_class_entry * ce , const char * name ) {
542
- #if ZEND_MODULE_API_NO >= ZEND_7_1_X_API_NO
543
420
zend_class_constant * constant = NULL ;
544
421
zval * copy = NULL ;
545
422
@@ -555,29 +432,6 @@ zval* nr_php_get_class_constant(const zend_class_entry* ce, const char* name) {
555
432
}
556
433
557
434
return copy ;
558
- #else
559
- zval * constant = NULL ;
560
- zval * copy = NULL ;
561
-
562
- if (NULL == ce ) {
563
- return NULL ;
564
- }
565
-
566
- constant = nr_php_zend_hash_find (& (ce -> constants_table ), name );
567
-
568
- if (constant ) {
569
- copy = nr_php_zval_alloc ();
570
-
571
- /*
572
- * PHP 7.0 usually returns an IS_REF. We need to unwrap to ensure that we
573
- * duplicate the concrete value, otherwise the caller will end up freeing a
574
- * value that it doesn't own, and bad things will happen.
575
- */
576
- ZVAL_DUP (copy , nr_php_zval_real_value (constant ));
577
- }
578
-
579
- return copy ;
580
- #endif
581
435
}
582
436
583
437
char * nr_php_get_object_constant (zval * app , const char * name ) {
@@ -649,17 +503,13 @@ int nr_php_is_zval_named_constant(const zval* zv, const char* name TSRMLS_DC) {
649
503
}
650
504
651
505
int nr_php_zend_is_auto_global (const char * name , size_t name_len TSRMLS_DC ) {
652
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
653
506
zend_bool rv ;
654
507
zend_string * zs = zend_string_init (name , name_len , 0 );
655
508
656
509
rv = zend_is_auto_global (zs );
657
510
658
511
zend_string_free (zs );
659
512
return rv ;
660
- #else
661
- return (int )zend_is_auto_global (name , (int )name_len TSRMLS_CC );
662
- #endif /* PHP7+ */
663
513
}
664
514
665
515
const char * nr_php_use_license (const char * api_license TSRMLS_DC ) {
@@ -687,11 +537,7 @@ char* nr_php_get_server_global(const char* name TSRMLS_DC) {
687
537
return NULL ;
688
538
}
689
539
690
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
691
540
global = & (PG (http_globals )[TRACK_VARS_SERVER ]);
692
- #else
693
- global = PG (http_globals )[TRACK_VARS_SERVER ];
694
- #endif
695
541
696
542
if (!nr_php_is_zval_valid_array (global )) {
697
543
return NULL ;
@@ -1014,11 +860,7 @@ char* nr_php_function_debug_name(const zend_function* func) {
1014
860
1015
861
if ((ZEND_USER_FUNCTION == func -> type )
1016
862
&& (func -> common .fn_flags & ZEND_ACC_CLOSURE )) {
1017
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
1018
863
const char * filename = ZSTR_VAL (func -> op_array .filename );
1019
- #else
1020
- const char * filename = func -> op_array .filename ;
1021
- #endif /* PHP7+ */
1022
864
char * orig_name = name ;
1023
865
1024
866
name = nr_formatf ("%s declared at %s:%d" , orig_name , NRSAFESTR (filename ),
0 commit comments