Skip to content

Commit a355258

Browse files
committed
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 846ff27 commit a355258

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

@@ -596,8 +598,15 @@ void extract_data(TSRMLS_D)
596598
zend_is_auto_global_compat("_COOKIE");
597599
if (FETCH_HTTP_GLOBALS(COOKIE)) {
598600
if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
601+
#if PHP_VERSION_ID >= 70100
602+
zend_string *tmpstr;
603+
tmpstr = zend_print_zval_r_to_str(tmp, 0);
604+
smart_str_append(&APM_RD(cookies), tmpstr);
605+
zend_string_release(tmpstr);
606+
#else
599607
APM_G(buffer) = &APM_RD(cookies);
600608
zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
609+
#endif
601610
APM_RD(cookies_found) = 1;
602611
}
603612
}
@@ -606,8 +615,15 @@ void extract_data(TSRMLS_D)
606615
zend_is_auto_global_compat("_POST");
607616
if (FETCH_HTTP_GLOBALS(POST)) {
608617
if (Z_ARRVAL_P(tmp)->nNumOfElements > 0) {
618+
#if PHP_VERSION_ID >= 70100
619+
zend_string *tmpstr;
620+
tmpstr = zend_print_zval_r_to_str(tmp, 0);
621+
smart_str_append(&APM_RD(post_vars), tmpstr);
622+
zend_string_release(tmpstr);
623+
#else
609624
APM_G(buffer) = &APM_RD(post_vars);
610625
zend_print_zval_r_ex(apm_write, tmp, 0 TSRMLS_CC);
626+
#endif
611627
APM_RD(post_vars_found) = 1;
612628
}
613629
}

php_apm.h

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

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

381-
void extract_data(TSRMLS_D);

0 commit comments

Comments
 (0)