Skip to content

Commit f4f8f6e

Browse files
remicolletpatrickallaert
authored andcommitted
Fix build with PHP 7.1
- zend_print_zval_r_ex have been removed from 7.1 - zend_print_zval_r_to_str have been added in 7.1 - make apm_write static (not used anywhere else) - move extract_data declaration
1 parent 21b050e commit f4f8f6e

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

apm.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ static int apm_end_silence_opcode_handler(ZEND_USER_OPCODE_HANDLER_ARGS)
9494
return ZEND_USER_OPCODE_DISPATCH;
9595
}
9696

97-
int apm_write(const char *str,
97+
#if PHP_VERSION_ID < 70100
98+
static int apm_write(const char *str,
9899
#if PHP_VERSION_ID >= 70000
99100
size_t
100101
#else
@@ -107,6 +108,7 @@ length)
107108
smart_str_0(APM_G(buffer));
108109
return length;
109110
}
111+
#endif
110112

111113
void (*old_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
112114

@@ -598,8 +600,15 @@ void extract_data(TSRMLS_D)
598600
zend_is_auto_global_compat("_COOKIE");
599601
if (FETCH_HTTP_GLOBALS(COOKIE)) {
600602
if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
603+
#if PHP_VERSION_ID >= 70100
604+
zend_string *tmpstr;
605+
tmpstr = zend_print_zval_r_to_str(tmp, 0);
606+
smart_str_append(&APM_RD(cookies), tmpstr);
607+
zend_string_release(tmpstr);
608+
#else
601609
APM_G(buffer) = &APM_RD(cookies);
602610
zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
611+
#endif
603612
APM_RD(cookies_found) = 1;
604613
}
605614
}
@@ -608,8 +617,15 @@ void extract_data(TSRMLS_D)
608617
zend_is_auto_global_compat("_POST");
609618
if (FETCH_HTTP_GLOBALS(POST)) {
610619
if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
620+
#if PHP_VERSION_ID >= 70100
621+
zend_string *tmpstr;
622+
tmpstr = zend_print_zval_r_to_str(tmp, 0);
623+
smart_str_append(&APM_RD(post_vars), tmpstr);
624+
zend_string_release(tmpstr);
625+
#else
611626
APM_G(buffer) = &APM_RD(post_vars);
612627
zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
628+
#endif
613629
APM_RD(post_vars_found) = 1;
614630
}
615631
}

php_apm.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,6 @@ ZEND_EXTERN_MODULE_GLOBALS(apm)
370370
# define add_assoc_long_compat(array, key, value) add_assoc_long_ex((array), (key), (sizeof(key)), (value));
371371
#endif
372372

373-
int apm_write(const char *str,
374-
#if PHP_VERSION_ID >= 70000
375-
size_t
376-
#else
377-
uint
378-
#endif
379-
length);
380-
373+
void extract_data(TSRMLS_D);
381374
#endif
382375

383-
void extract_data(TSRMLS_D);

0 commit comments

Comments
 (0)