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/scout_utils.c b/scout_utils.c
index 424c782..a06c1ab 100644
--- a/scout_utils.c
+++ b/scout_utils.c
@@ -89,11 +89,24 @@ 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;
+ 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 */
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;
}
}
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--