Skip to content

Commit

Permalink
Merge pull request #100 from scoutapp/remicollet-issue-98
Browse files Browse the repository at this point in the history
call json_encode using call_user_func on PHP 7
  • Loading branch information
asgrim authored Dec 24, 2021
2 parents 2d1c843 + 43aef15 commit 6b558f6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 21 additions & 5 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
</lead>

<!-- Current Release -->
<date>2021-12-23</date>
<time>09:00:00</time>
<date>2021-12-24</date>
<time>14:00:00</time>
<version>
<release>1.5.0</release>
<api>1.5.0</api>
<release>1.5.1</release>
<api>1.5.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="https://opensource.org/licenses/MIT">MIT</license>
<notes>
- 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)
</notes>
<!-- End Current Release -->

Expand Down Expand Up @@ -114,6 +114,22 @@
<zendextsrcrelease />

<changelog>
<release>
<date>2021-12-23</date>
<time>09:00:00</time>
<version>
<release>1.5.0</release>
<api>1.5.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="https://opensource.org/licenses/MIT">MIT</license>
<notes>
- file_get_contents and curl_exec now record HTTP methods (#96)
</notes>
</release>
<release>
<date>2021-10-29</date>
<time>09:00:00</time>
Expand Down
13 changes: 13 additions & 0 deletions scout_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/019-url-method-capture-fgc.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Both URL and Method can be captured using file_get_contents
--SKIPIF--
<?php if (!extension_loaded("scoutapm")) die("skip scoutapm extension required."); ?>
<?php if (!extension_loaded("json")) die("skip json extension required."); ?>
--FILE--
<?php

Expand Down
2 changes: 1 addition & 1 deletion zend_scoutapm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b558f6

Please sign in to comment.