@@ -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
}
@@ -462,41 +404,20 @@ zval* nr_php_get_user_func_arg(size_t requested_arg_index,
462
404
return NULL ;
463
405
}
464
406
465
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
466
407
(void )arg_count_via_h ;
467
408
468
409
if (requested_arg_index > ZEND_CALL_NUM_ARGS (execute_data )) {
469
410
return NULL ;
470
411
}
471
412
472
413
arg_via_h = ZEND_CALL_ARG (execute_data , requested_arg_index );
473
- #else
474
- arg_via_h = nr_php_get_user_func_arg_via_h (
475
- requested_arg_index , & arg_count_via_h , NR_EXECUTE_ORIG_ARGS TSRMLS_CC );
476
- #endif /* PHP7+ */
477
414
478
415
return arg_via_h ;
479
416
}
480
417
481
418
size_t nr_php_get_user_func_arg_count (NR_EXECUTE_PROTO TSRMLS_DC ) {
482
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
483
419
NR_UNUSED_FUNC_RETURN_VALUE ;
484
420
return (size_t )ZEND_CALL_NUM_ARGS (execute_data );
485
- #else
486
- int arg_count_via_h = -1 ;
487
-
488
- if (NULL
489
- == nr_php_get_user_func_arg_via_h (1 , & arg_count_via_h ,
490
- NR_EXECUTE_ORIG_ARGS TSRMLS_CC )) {
491
- return 0 ;
492
- } else if (arg_count_via_h < 0 ) {
493
- nrl_verbosedebug (NRL_AGENT , "%s: unexpected argument count %d" , __func__ ,
494
- arg_count_via_h );
495
- return 0 ;
496
- }
497
-
498
- return (size_t )arg_count_via_h ;
499
- #endif /* PHP7+ */
500
421
}
501
422
502
423
zend_execute_data * nr_php_get_caller_execute_data (NR_EXECUTE_PROTO ,
@@ -525,30 +446,18 @@ zend_execute_data* nr_php_get_caller_execute_data(NR_EXECUTE_PROTO,
525
446
ced = ced -> prev_execute_data ;
526
447
}
527
448
528
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
529
449
if ((NULL == ced ) || (NULL == ced -> opline )) {
530
450
return NULL ;
531
451
}
532
- #else
533
- if ((NULL == ced ) || (NULL == ced -> op_array )) {
534
- return NULL ;
535
- }
536
- #endif /* PHP7+ */
537
452
538
453
if ((ZEND_DO_FCALL != ced -> opline -> opcode )
539
454
&& (ZEND_DO_FCALL_BY_NAME != ced -> opline -> opcode )) {
540
455
return NULL ;
541
456
}
542
457
543
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
544
458
if (NULL == ced -> func ) {
545
459
return NULL ;
546
460
}
547
- #else
548
- if (0 == ced -> function_state .function ) {
549
- return NULL ;
550
- }
551
- #endif /* PHP7+ */
552
461
553
462
return ced ;
554
463
}
@@ -562,17 +471,12 @@ const zend_function* nr_php_get_caller(NR_EXECUTE_PROTO,
562
471
return NULL ;
563
472
}
564
473
565
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
566
474
return ped -> func ;
567
- #else
568
- return ped -> function_state .function ;
569
- #endif /* PHP7+ */
570
475
}
571
476
572
477
zval * nr_php_get_active_php_variable (const char * name TSRMLS_DC ) {
573
478
HashTable * table ;
574
479
575
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
576
480
table = zend_rebuild_symbol_table ();
577
481
578
482
/*
@@ -586,10 +490,6 @@ zval* nr_php_get_active_php_variable(const char* name TSRMLS_DC) {
586
490
* https://nikic.github.io/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html#indirect-zvals
587
491
*/
588
492
return nr_php_zval_direct (nr_php_zend_hash_find (table , name ));
589
- #else
590
- table = EG (active_symbol_table );
591
- return nr_php_zend_hash_find (table , name );
592
- #endif /* PHP7+ */
593
493
}
594
494
595
495
int nr_php_silence_errors (TSRMLS_D ) {
@@ -605,7 +505,6 @@ void nr_php_restore_errors(int error_reporting TSRMLS_DC) {
605
505
}
606
506
607
507
zval * nr_php_get_constant (const char * name TSRMLS_DC ) {
608
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
609
508
zval * constant ;
610
509
zval * copy = NULL ;
611
510
zend_string * name_str ;
@@ -629,31 +528,9 @@ zval* nr_php_get_constant(const char* name TSRMLS_DC) {
629
528
ZVAL_DUP (copy , constant );
630
529
631
530
return copy ;
632
- #else
633
- nr_string_len_t len ;
634
- int rv ;
635
- zval * constant = NULL ;
636
-
637
- if (NULL == name ) {
638
- return NULL ;
639
- }
640
-
641
- len = nr_strlen (name );
642
- constant = nr_php_zval_alloc ();
643
-
644
- /* zend_get_constant returns 0 and 1 (not SUCCESS or FAILURE) */
645
- rv = zend_get_constant (name , len , constant TSRMLS_CC );
646
- if (0 == rv ) {
647
- nr_php_zval_free (& constant );
648
- return NULL ;
649
- }
650
-
651
- return constant ;
652
- #endif /* PHP7+ */
653
531
}
654
532
655
533
zval * nr_php_get_class_constant (const zend_class_entry * ce , const char * name ) {
656
- #if ZEND_MODULE_API_NO >= ZEND_7_1_X_API_NO
657
534
zend_class_constant * constant = NULL ;
658
535
zval * copy = NULL ;
659
536
@@ -669,29 +546,6 @@ zval* nr_php_get_class_constant(const zend_class_entry* ce, const char* name) {
669
546
}
670
547
671
548
return copy ;
672
- #else
673
- zval * constant = NULL ;
674
- zval * copy = NULL ;
675
-
676
- if (NULL == ce ) {
677
- return NULL ;
678
- }
679
-
680
- constant = nr_php_zend_hash_find (& (ce -> constants_table ), name );
681
-
682
- if (constant ) {
683
- copy = nr_php_zval_alloc ();
684
-
685
- /*
686
- * PHP 7.0 usually returns an IS_REF. We need to unwrap to ensure that we
687
- * duplicate the concrete value, otherwise the caller will end up freeing a
688
- * value that it doesn't own, and bad things will happen.
689
- */
690
- ZVAL_DUP (copy , nr_php_zval_real_value (constant ));
691
- }
692
-
693
- return copy ;
694
- #endif
695
549
}
696
550
697
551
char * nr_php_get_object_constant (zval * app , const char * name ) {
@@ -763,17 +617,13 @@ int nr_php_is_zval_named_constant(const zval* zv, const char* name TSRMLS_DC) {
763
617
}
764
618
765
619
int nr_php_zend_is_auto_global (const char * name , size_t name_len TSRMLS_DC ) {
766
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
767
620
zend_bool rv ;
768
621
zend_string * zs = zend_string_init (name , name_len , 0 );
769
622
770
623
rv = zend_is_auto_global (zs );
771
624
772
625
zend_string_free (zs );
773
626
return rv ;
774
- #else
775
- return (int )zend_is_auto_global (name , (int )name_len TSRMLS_CC );
776
- #endif /* PHP7+ */
777
627
}
778
628
779
629
const char * nr_php_use_license (const char * api_license TSRMLS_DC ) {
@@ -801,11 +651,7 @@ char* nr_php_get_server_global(const char* name TSRMLS_DC) {
801
651
return NULL ;
802
652
}
803
653
804
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
805
654
global = & (PG (http_globals )[TRACK_VARS_SERVER ]);
806
- #else
807
- global = PG (http_globals )[TRACK_VARS_SERVER ];
808
- #endif
809
655
810
656
if (!nr_php_is_zval_valid_array (global )) {
811
657
return NULL ;
@@ -1128,11 +974,7 @@ char* nr_php_function_debug_name(const zend_function* func) {
1128
974
1129
975
if ((ZEND_USER_FUNCTION == func -> type )
1130
976
&& (func -> common .fn_flags & ZEND_ACC_CLOSURE )) {
1131
- #if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */
1132
977
const char * filename = ZSTR_VAL (func -> op_array .filename );
1133
- #else
1134
- const char * filename = func -> op_array .filename ;
1135
- #endif /* PHP7+ */
1136
978
char * orig_name = name ;
1137
979
1138
980
name = nr_formatf ("%s declared at %s:%d" , orig_name , NRSAFESTR (filename ),
0 commit comments