diff --git a/.travis.yml b/.travis.yml index 1067bf2..b8fcbc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: c env: + - MO_PHP_VERSION=7.4.3 + - MO_PHP_VERSION=7.3.2 - MO_PHP_VERSION=7.2.2 - MO_PHP_VERSION=7.1.2 - MO_PHP_VERSION=7.0.16 diff --git a/.travis/ext_install.sh b/.travis/ext_install.sh index e3f34c0..6205edf 100755 --- a/.travis/ext_install.sh +++ b/.travis/ext_install.sh @@ -26,7 +26,7 @@ fi if [ "$PHP_MAJOR" -eq "7" ] ;then #ls -a $MO_EX_DIR |grep memcached || printf "\n" | $PHP_PECL install -f --ignore-errors memcached-3.0.2 -ls -a $MO_EX_DIR |grep memcached || (wget http://pecl.php.net/get/memcached-3.0.2.tgz && tar xf memcached-3.0.2.tgz && cd memcached-3.0.2 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install) +ls -a $MO_EX_DIR |grep memcached || (wget http://pecl.php.net/get/memcached-3.1.0.tgz && tar xf memcached-3.1.0.tgz && cd memcached-3.1.0 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install) else #ls -a $MO_EX_DIR |grep memcached || printf "\n" | $PHP_PECL install -f --ignore-errors memcached-2.2.0 ls -a $MO_EX_DIR |grep 1memcached || (wget http://pecl.php.net/get/memcached-2.2.0.tgz && tar xf memcached-2.2.0.tgz && cd memcached-2.2.0 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install) diff --git a/.travis/php_build.sh b/.travis/php_build.sh index 6e178e1..8cd967e 100755 --- a/.travis/php_build.sh +++ b/.travis/php_build.sh @@ -60,8 +60,10 @@ function build() # prepare param_general="--disable-all $param_debug" param_sapi="--enable-cli --enable-cgi" + if [ ${version:0:3} == "7.3" ]; then + param_ext="--without-libzip" # hack for PHP 5.2 - if [ ${version:0:3} == "5.2" ]; then + elif [ ${version:0:3} == "5.2" ]; then # pcre: run-tests.php # spl: spl_autoload_register in trace's tests param_ext="--with-pcre-regex --enable-spl" diff --git a/molten.c b/molten.c index 2275ff3..708a35b 100644 --- a/molten.c +++ b/molten.c @@ -44,6 +44,11 @@ } \ }while(0) +#if PHP_VERSION_ID < 70300 +#define MO_HASH_FLAG_PERSISTENT HASH_FLAG_PERSISTENT +#else +#define MO_HASH_FLAG_PERSISTENT IS_ARRAY_PERSISTENT +#endif PHP_FUNCTION(molten_curl_setopt); PHP_FUNCTION(molten_curl_exec); @@ -176,16 +181,16 @@ static void molten_reload_curl_function() orig->common.fn_flags = ZEND_ACC_PUBLIC; //Set orig handle if(!strcmp(p->orig_func,"curl_setopt")) { - origin_curl_setopt = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT); + origin_curl_setopt = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT); memcpy(origin_curl_setopt, orig, sizeof(zend_internal_function)); } else if (!strcmp(p->orig_func,"curl_exec")) { - origin_curl_exec = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT); + origin_curl_exec = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT); memcpy(origin_curl_exec, orig, sizeof(zend_internal_function)); } else if (!strcmp(p->orig_func,"curl_setopt_array")) { - origin_curl_setopt_array = pemalloc(sizeof(zend_internal_function) , HASH_FLAG_PERSISTENT); + origin_curl_setopt_array = pemalloc(sizeof(zend_internal_function) , MO_HASH_FLAG_PERSISTENT); memcpy(origin_curl_setopt_array, orig, sizeof(zend_internal_function)); } else if (!strcmp(p->orig_func,"curl_reset")) { - origin_curl_reset = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT); + origin_curl_reset = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT); memcpy(origin_curl_reset, orig, sizeof(zend_internal_function)); } function_add_ref(orig); diff --git a/molten_intercept.c b/molten_intercept.c index 05a8682..3b06759 100644 --- a/molten_intercept.c +++ b/molten_intercept.c @@ -97,7 +97,7 @@ static char *convert_args_to_string(mo_frame_t *frame) int stop = 0; memset(string, 0x00, ARGS_MAX_LEN); arg_len = smart_string_len(frame->function) + 1; - string = strncat(string, smart_string_str(frame->function), real_len - 1); + string = strncat(string, smart_string_str(frame->function), arg_len - 1); string = strncat(string, " ", 1); for (; i < frame->arg_count; i++) { @@ -335,7 +335,13 @@ static char *pcre_common_match(char *pattern, int len, char *subject) #else if ((cache = pcre_get_compiled_regex_cache(pattern, len)) != NULL) { #endif + +#if PHP_VERSION_ID >= 70400 + zend_string *str = zend_string_init(subject, strlen(subject), 0); + php_pcre_match_impl(cache, str, result, subpats, 0, 0, 0, 0 TSRMLS_CC); +#else php_pcre_match_impl(cache, subject, strlen(subject), result, subpats, 0, 0, 0, 0 TSRMLS_CC); +#endif zval *match = NULL; if (Z_LVAL_P(result) > 0 && MO_Z_TYPE_P(subpats) == IS_ARRAY) { #if PHP_VERSION_ID >= 70000 @@ -1171,7 +1177,11 @@ static void mongodb_record(mo_interceptor_t *pit, mo_frame_t *frame) /* read url from debug info */ zval *obj = frame->object; int is_temp; +#if PHP_VERSION_ID >= 70400 + HashTable *debug_hash = zend_get_properties_for(obj, ZEND_PROP_PURPOSE_DEBUG); +#else HashTable *debug_hash = Z_OBJDEBUG_P(obj, is_temp); +#endif zval *uri = NULL; if (mo_zend_hash_zval_find(debug_hash, "uri", sizeof("uri"), (void **)&uri) == SUCCESS) { if (uri != NULL && MO_Z_TYPE_P(uri) == IS_STRING) { @@ -1208,7 +1218,11 @@ static void mongodb_server_record(mo_interceptor_t *pit, mo_frame_t *frame) /* read url from debug info */ zval *obj = frame->object; int is_temp; +#if PHP_VERSION_ID >= 70400 + HashTable *debug_hash = zend_get_properties_for(obj, ZEND_PROP_PURPOSE_DEBUG); +#else HashTable *debug_hash = Z_OBJDEBUG_P(obj, is_temp); +#endif zval *host = NULL; zval *port = NULL; if (mo_zend_hash_zval_find(debug_hash, "host", sizeof("host"), (void **)&host) == SUCCESS) { @@ -1342,7 +1356,11 @@ static void es_request_record(mo_interceptor_t *pit, mo_frame_t *frame) if (MO_Z_TYPE_P(&host) == IS_STRING) { php_url *url = php_url_parse(Z_STRVAL(host)); if (url != NULL) { +#if PHP_VERSION_ID >= 70400 + pit->psb->span_add_ba(span, "sa", "true", frame->exit_time, "es", ZSTR_VAL(url->host), url->port, BA_SA); +#else pit->psb->span_add_ba(span, "sa", "true", frame->exit_time, "es", url->host, url->port, BA_SA); +#endif } else { pit->psb->span_add_ba_ex(span, "php.db.data_source", Z_STRVAL(host), frame->exit_time, pit->pct, BA_NORMAL); diff --git a/php7_wrapper.h b/php7_wrapper.h index 75547f8..04f7295 100644 --- a/php7_wrapper.h +++ b/php7_wrapper.h @@ -249,7 +249,11 @@ static inline void mo_array_merge(zval *dest, zval *src TSRMLS_DC) static inline void array_init_persist(zval *arg ZEND_FILE_LINE_DC) { ZVAL_NEW_PERSISTENT_ARR(arg); +#if PHP_VERSION_ID < 70300 _zend_hash_init(Z_ARRVAL_P(arg), 0, ZVAL_PTR_DTOR, 1 ZEND_FILE_LINE_RELAY_CC); +#else + _zend_hash_init(Z_ARRVAL_P(arg), 0, ZVAL_PTR_DTOR, 1); +#endif } static inline void array_free_persist(zval *arg) diff --git a/tests/bug_connect_error_db_7.phpt b/tests/bug_connect_error_db_7.phpt index a1b3d1a..22be892 100644 --- a/tests/bug_connect_error_db_7.phpt +++ b/tests/bug_connect_error_db_7.phpt @@ -35,9 +35,9 @@ Warning: mysqli::query(): invalid object or resource mysqli Warning: mysqli_connect(): (HY000/2002): %s on line 7 -Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line 8 +Warning: mysqli_query() expects parameter 1 to be mysqli, %s given in %s on line 8 -Warning: mysqli_prepare() expects parameter 1 to be mysqli, boolean given in %s on line 9 +Warning: mysqli_prepare() expects parameter 1 to be mysqli, %s given in %s on line 9 Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, null given in %s on line 10 diff --git a/tests/molten_005.phpt b/tests/molten_005.phpt index fc9547d..114b9e8 100644 --- a/tests/molten_005.phpt +++ b/tests/molten_005.phpt @@ -17,7 +17,7 @@ include 'mysqli_execute.inc'; mysqli_exec($true_db, "select * from configs_not_exist"); ?> --EXPECTF-- -Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in %s on line 10 +Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, %s given in %s on line 10 {"traceId":"%s","name":"mysqli_connect","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]} {"traceId":"%s","name":"mysqli_query","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"db.statement","value":"select * from configs_not_exist","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"db.type","value":"mysql","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]} {"traceId":"%s","name":"mysqli_prepare","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"db.statement","value":"select * from configs_not_exist","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"db.type","value":"mysql","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]}