From 44ff59b2061baba4e0f32d783f7e7051c48f0e97 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 22 Jan 2019 16:39:19 +0100 Subject: update to 0.10.0 open https://github.com/DataDog/dd-trace-php/issues/249 missing files open https://github.com/DataDog/dd-trace-php/issues/250 PHP compat --- PHPINFO | 7 ++- REFLECTION | 9 +++- php-pecl-datadog-trace.spec | 21 ++++----- request_hooks.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ request_hooks.h | 9 ++++ 5 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 request_hooks.c create mode 100644 request_hooks.h diff --git a/PHPINFO b/PHPINFO index 148d9e6..b05b0ad 100644 --- a/PHPINFO +++ b/PHPINFO @@ -7,4 +7,9 @@ For help, check out the documentation at https://github.com/DataDog/dd-trace-php (c) Datadog 2018 Datadog tracing support => enabled -Version => 0.9.1-beta +Version => 0.10.0-beta + +Directive => Local Value => Master Value +ddtrace.disable => 0 => 0 +ddtrace.request_init_hook => no value => no value +ddtrace.ignore_missing_overridables => 1 => 1 diff --git a/REFLECTION b/REFLECTION index eaf6668..61041d4 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,9 +1,12 @@ -Extension [ extension #84 ddtrace version 0.9.1-beta ] { +Extension [ extension #84 ddtrace version 0.10.0-beta ] { - INI { Entry [ ddtrace.disable ] Current = '0' } + Entry [ ddtrace.request_init_hook ] + Current = '' + } Entry [ ddtrace.ignore_missing_overridables ] Current = '1' } @@ -14,6 +17,10 @@ Extension [ extension #84 ddtrace version 0.9.1-beta ] { } Function [ function dd_trace_reset ] { } + Function [ function dd_trace_noop ] { + } + Function [ function dd_untrace ] { + } } } diff --git a/php-pecl-datadog-trace.spec b/php-pecl-datadog-trace.spec index b1b76ac..7b757b1 100644 --- a/php-pecl-datadog-trace.spec +++ b/php-pecl-datadog-trace.spec @@ -30,11 +30,13 @@ Summary: APM and distributed tracing for PHP Name: %{?sub_prefix}php-pecl-datadog-trace -Version: 0.9.1 +Version: 0.10.0 Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: MIT URL: http://pecl.php.net/package/%{proj_name} Source0: http://pecl.php.net/get/%{proj_name}-%{version}.tgz +Source1: https://raw.githubusercontent.com/DataDog/dd-trace-php/038957d286d6c9b65dd98d1c9a7893b66839bc98/src/ext/request_hooks.h +Source2: https://raw.githubusercontent.com/DataDog/dd-trace-php/038957d286d6c9b65dd98d1c9a7893b66839bc98/src/ext/request_hooks.c BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel > 5.6 @@ -55,14 +57,6 @@ Provides: %{?scl_prefix}php-pecl-%{safe_name}%{?_isa} = %{version}-%{rele %if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff -%if "%{php_version}" > "5.6" -Obsoletes: php56u-pecl-%{safe_name} <= %{version} -Obsoletes: php56w-pecl-%{safe_name} <= %{version} -%endif -%if "%{php_version}" > "7.0" -Obsoletes: php70u-pecl-%{safe_name} <= %{version} -Obsoletes: php70w-pecl-%{safe_name} <= %{version} -%endif %if "%{php_version}" > "7.1" Obsoletes: php71u-pecl-%{safe_name} <= %{version} Obsoletes: php71w-pecl-%{safe_name} <= %{version} @@ -93,6 +87,7 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO %prep %setup -q -c mv %{proj_name}-%{version} NTS +cp %{SOURCE1} %{SOURCE2} NTS/src/ext/ # Don't install tests sed -e 's/role="test"/role="src"/' \ @@ -118,8 +113,9 @@ cat << 'EOF' | tee %{ini_name} ; Enable %{pecl_name} extension module extension=%{pecl_name}.so -; Configuraton +; Configuration ;ddtrace.disable = 0 +;ddtrace.request_init_hook = '' ;ddtrace.ignore_missing_overridables = 1 EOF @@ -232,6 +228,11 @@ fi %changelog +* Tue Jan 22 2019 Remi Collet - 0.10.0-1 +- update to 0.10.0 +- open https://github.com/DataDog/dd-trace-php/issues/249 missing files +- open https://github.com/DataDog/dd-trace-php/issues/250 PHP compat + * Sat Jan 12 2019 Remi Collet - 0.9.1-1 - update to 0.9.1 diff --git a/request_hooks.c b/request_hooks.c new file mode 100644 index 0000000..c4f5f53 --- /dev/null +++ b/request_hooks.c @@ -0,0 +1,101 @@ +#include "request_hooks.h" +#include "compat_zend_string.h" + +#include +#include +#include + +#if PHP_VERSION_ID < 70000 +int dd_execute_php_file(const char *filename TSRMLS_DC) { + int filename_len = strlen(filename); + if (filename_len == 0) { + return FAILURE; + } + int dummy = 1; + zend_file_handle file_handle; + zend_op_array *new_op_array; + zval *result = NULL; + int ret; + + ret = php_stream_open_for_zend_ex(filename, &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); + + if (ret == SUCCESS) { + if (!file_handle.opened_path) { + file_handle.opened_path = estrndup(filename, filename_len); + } + if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path) + 1, + (void *)&dummy, sizeof(int), NULL) == SUCCESS) { + new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC); + zend_destroy_file_handle(&file_handle TSRMLS_CC); + } else { + new_op_array = NULL; + zend_file_handle_dtor(&file_handle TSRMLS_CC); + } + if (new_op_array) { + EG(return_value_ptr_ptr) = &result; + EG(active_op_array) = new_op_array; + if (!EG(active_symbol_table)) { + zend_rebuild_symbol_table(TSRMLS_C); + } + + zend_execute(new_op_array TSRMLS_CC); + + destroy_op_array(new_op_array TSRMLS_CC); + efree(new_op_array); + if (!EG(exception)) { + if (EG(return_value_ptr_ptr)) { + zval_ptr_dtor(EG(return_value_ptr_ptr)); + } + } + + return 1; + } + } + return 0; +} +#else + +int dd_execute_php_file(const char *filename TSRMLS_DC) { + int filename_len = strlen(filename); + if (filename_len == 0) { + return FAILURE; + } + zval dummy; + zend_file_handle file_handle; + zend_op_array *new_op_array; + zval result; + int ret; + + ret = php_stream_open_for_zend_ex(filename, &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE); + + if (ret == SUCCESS) { + zend_string *opened_path; + if (!file_handle.opened_path) { + file_handle.opened_path = zend_string_init(filename, filename_len, 0); + } + opened_path = zend_string_copy(file_handle.opened_path); + ZVAL_NULL(&dummy); + if (zend_hash_add(&EG(included_files), opened_path, &dummy)) { + new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE); + zend_destroy_file_handle(&file_handle); + } else { + new_op_array = NULL; + zend_file_handle_dtor(&file_handle); + } + zend_string_release(opened_path); + if (new_op_array) { + ZVAL_UNDEF(&result); + zend_execute(new_op_array, &result); + + destroy_op_array(new_op_array); + efree(new_op_array); + if (!EG(exception)) { + zval_ptr_dtor(&result); + } + + return 1; + } + } + return 0; +} +#endif diff --git a/request_hooks.h b/request_hooks.h new file mode 100644 index 0000000..449347b --- /dev/null +++ b/request_hooks.h @@ -0,0 +1,9 @@ +#ifndef REQUEST_HOOKS_H +#define REQUEST_HOOKS_H + +#include +#include + +int dd_execute_php_file(const char *filename TSRMLS_DC); + +#endif // REQUEST_HOOKS_H -- cgit