From cf2e24d788d9d31715c272197417cb03283acd40 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 23 Dec 2021 14:43:51 +0100 Subject: [PATCH 1/4] call json_encode using call_user_func on PHP 7 --- scout_utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scout_utils.c b/scout_utils.c index 424c782..ea975db 100644 --- a/scout_utils.c +++ b/scout_utils.c @@ -89,11 +89,21 @@ void safely_copy_argument_zval_as_scalar(zval *original_to_copy, zval *destinati if (strcasecmp("stream-context", zend_rsrc_list_get_rsrc_type(Z_RES_P(original_to_copy))) == 0) { php_stream_context *stream_context = zend_fetch_resource_ex(original_to_copy, NULL, php_le_stream_context()); if (stream_context != NULL) { +#if PHP_VERSION_ID < 80000 + /* ext/json can be shared */ + zval args[1], jsonenc; + + ZVAL_STRINGL(&jsonenc, "json_encode", sizeof("json_encode")-1); + args[0] = stream_context->options; + call_user_function(EG(function_table), NULL, &jsonenc, destination, 1, args); +#else + /* ext/json is always there */ smart_str json_encode_string_buffer = {0}; php_json_encode(&json_encode_string_buffer, &stream_context->options, 0); smart_str_0(&json_encode_string_buffer); ZVAL_STR_COPY(destination, json_encode_string_buffer.s); smart_str_free(&json_encode_string_buffer); +#endif return; } } From c6d73c8cf5f214651b354a5678241b27370ecd01 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 23 Dec 2021 15:03:31 +0100 Subject: [PATCH 2/4] memleak --- scout_utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scout_utils.c b/scout_utils.c index ea975db..5b45af5 100644 --- a/scout_utils.c +++ b/scout_utils.c @@ -96,6 +96,7 @@ void safely_copy_argument_zval_as_scalar(zval *original_to_copy, zval *destinati ZVAL_STRINGL(&jsonenc, "json_encode", sizeof("json_encode")-1); args[0] = stream_context->options; call_user_function(EG(function_table), NULL, &jsonenc, destination, 1, args); + zval_ptr_dtor(&jsonenc); #else /* ext/json is always there */ smart_str json_encode_string_buffer = {0}; From d231a1b58c8eb7a7750b89821555ed8074255c46 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Fri, 24 Dec 2021 14:48:36 +0000 Subject: [PATCH 3/4] Use NULL as the value if json_encode call fails --- scout_utils.c | 4 +++- tests/019-url-method-capture-fgc.phpt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scout_utils.c b/scout_utils.c index 5b45af5..a06c1ab 100644 --- a/scout_utils.c +++ b/scout_utils.c @@ -95,7 +95,9 @@ void safely_copy_argument_zval_as_scalar(zval *original_to_copy, zval *destinati ZVAL_STRINGL(&jsonenc, "json_encode", sizeof("json_encode")-1); args[0] = stream_context->options; - call_user_function(EG(function_table), NULL, &jsonenc, destination, 1, args); + if (FAILURE == call_user_function(EG(function_table), NULL, &jsonenc, destination, 1, args)) { + ZVAL_NULL(destination); + } zval_ptr_dtor(&jsonenc); #else /* ext/json is always there */ diff --git a/tests/019-url-method-capture-fgc.phpt b/tests/019-url-method-capture-fgc.phpt index 21e89d9..49eed5e 100644 --- a/tests/019-url-method-capture-fgc.phpt +++ b/tests/019-url-method-capture-fgc.phpt @@ -2,6 +2,7 @@ Both URL and Method can be captured using file_get_contents --SKIPIF-- + --FILE-- Date: Fri, 24 Dec 2021 14:54:57 +0000 Subject: [PATCH 4/4] Updates for 1.5.1 release --- CHANGELOG.md | 22 ++++++++++++++++++++++ package.xml | 26 +++++++++++++++++++++----- zend_scoutapm.h | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9138d3..98e2f6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 1.5.1 - 2021-12-24 + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#100](https://github.com/scoutapp/scout-apm-php-ext/pull/100) Fix json_encode usage where ext-json is shared or does not exist - thanks @remicollet + ## 1.5.0 - 2021-12-23 ### Added diff --git a/package.xml b/package.xml index 203035c..fabd32b 100644 --- a/package.xml +++ b/package.xml @@ -25,11 +25,11 @@ - 2021-12-23 - + 2021-12-24 + - 1.5.0 - 1.5.0 + 1.5.1 + 1.5.1 stable @@ -37,7 +37,7 @@ MIT - - file_get_contents and curl_exec now record HTTP methods (#96) + - Fix json_encode usage where ext-json is shared or does not exist - thanks @remicollet (#100) @@ -114,6 +114,22 @@ + + 2021-12-23 + + + 1.5.0 + 1.5.0 + + + stable + stable + + MIT + + - file_get_contents and curl_exec now record HTTP methods (#96) + + 2021-10-29 diff --git a/zend_scoutapm.h b/zend_scoutapm.h index f92be4e..014a389 100644 --- a/zend_scoutapm.h +++ b/zend_scoutapm.h @@ -21,7 +21,7 @@ #include "scout_execute_ex.h" #define PHP_SCOUTAPM_NAME "scoutapm" -#define PHP_SCOUTAPM_VERSION "1.5.0" +#define PHP_SCOUTAPM_VERSION "1.5.1" /* Extreme amounts of debugging, set to 1 to enable it and `make clean && make` (tests will fail...) */ #define SCOUT_APM_EXT_DEBUGGING 0