Skip to content

Commit c2a7a59

Browse files
committed
Update to compatibility with latest master
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 6b55c3e commit c2a7a59

11 files changed

Lines changed: 50 additions & 18 deletions

File tree

ext/compat_string.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ zend_string *ddtrace_convert_to_str(const zval *op) {
8484
case IS_STRING:
8585
return zend_string_copy(Z_STR_P(op));
8686

87-
EMPTY_SWITCH_DEFAULT_CASE()
87+
default:
88+
ZEND_UNREACHABLE();
8889
}
8990
}
9091

ext/engine_hooks.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ typedef struct ddtrace_error_handling ddtrace_error_handling;
4242

4343
struct ddtrace_sandbox_backup {
4444
ddtrace_error_handling eh;
45-
zend_object *exception, *prev_exception;
45+
zend_object *exception;
46+
#if PHP_VERSION_ID < 80600
47+
zend_object *prev_exception;
48+
#endif
4649
};
4750
typedef struct ddtrace_sandbox_backup ddtrace_sandbox_backup;
4851

@@ -70,12 +73,19 @@ inline void ddtrace_maybe_clear_exception(void) {
7073
}
7174

7275
inline ddtrace_sandbox_backup ddtrace_sandbox_begin(void) {
73-
ddtrace_sandbox_backup backup = {.exception = NULL, .prev_exception = NULL};
76+
ddtrace_sandbox_backup backup = {
77+
.exception = NULL,
78+
#if PHP_VERSION_ID < 80600
79+
.prev_exception = NULL,
80+
#endif
81+
};
7482
if (EG(exception)) {
7583
backup.exception = EG(exception);
76-
backup.prev_exception = EG(prev_exception);
7784
EG(exception) = NULL;
85+
#if PHP_VERSION_ID < 80600
86+
backup.prev_exception = EG(prev_exception);
7887
EG(prev_exception) = NULL;
88+
#endif
7989
}
8090
ddtrace_backup_error_handling(&backup.eh, EH_THROW);
8191
return backup;
@@ -87,7 +97,9 @@ inline void ddtrace_sandbox_end(ddtrace_sandbox_backup *backup) {
8797

8898
if (backup->exception) {
8999
EG(exception) = backup->exception;
100+
#if PHP_VERSION_ID < 80600
90101
EG(prev_exception) = backup->prev_exception;
102+
#endif
91103
zend_throw_exception_internal(NULL);
92104
}
93105
}

ext/handlers_kafka.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ZEND_FUNCTION(ddtrace_kafka_produce) {
7070
zval function_name;
7171
ZVAL_STRING(&function_name, "producev");
7272
call_user_function(NULL, getThis(), &function_name, return_value, 6 + opaque_param, args);
73-
zval_dtor(&function_name);
73+
zval_ptr_dtor_nogc(&function_name);
7474

7575
zend_string_release(Z_STR(args[2]));
7676
zend_string_release(Z_STR(args[3]));

ext/hook/uhook_legacy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static bool _parse_config_array(zval *config_array, zval **prehook, zval **posth
296296
return false;
297297
}
298298
} else if (strcmp("recurse", ZSTR_VAL(key)) == 0) {
299-
*allow_recursion = zval_is_true(value);
299+
*allow_recursion = zend_is_true(value);
300300
} else {
301301
LOG_LINE_ONCE(WARN, "Unknown option '%s' in config_array", ZSTR_VAL(key));
302302
return false;

ext/serializer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,10 +1225,10 @@ static bool should_track_error(zend_object *exception, ddtrace_span_data *span)
12251225
zend_array *meta = ddtrace_property_array(&span->property_meta);
12261226

12271227
// Check if error should be ignored or tracking is disabled
1228-
if ((zv = zend_hash_str_find(meta, ZEND_STRL("error.ignored"))) && zval_is_true(zv)) {
1228+
if ((zv = zend_hash_str_find(meta, ZEND_STRL("error.ignored"))) && zend_is_true(zv)) {
12291229
return false;
12301230
}
1231-
if ((zv = zend_hash_str_find(meta, ZEND_STRL("track_error"))) && !zval_is_true(zv)) {
1231+
if ((zv = zend_hash_str_find(meta, ZEND_STRL("track_error"))) && !zend_is_true(zv)) {
12321232
return false;
12331233
}
12341234
return true;

zend_abstract_interface/config/config_decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static bool zai_config_decode_json(zai_str value, zval *decoded_value, bool pers
257257
if (persistent) {
258258
zval_internal_ptr_dtor(decoded_value);
259259
} else {
260-
zval_dtor(decoded_value);
260+
zval_ptr_dtor_nogc(decoded_value);
261261
}
262262
ZVAL_NULL(decoded_value);
263263
return false;

zend_abstract_interface/config/config_ini.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ static ZEND_INI_MH(ZaiConfigOnUpdateIni) {
216216
}
217217

218218
if (!zai_config_is_initialized()) {
219-
zval_dtor(&new_zv);
219+
zval_ptr_dtor_nogc(&new_zv);
220220
return SUCCESS;
221221
}
222222

223223
if (memoized->ini_change && !memoized->ini_change(zai_config_get_value(id), &new_zv, new_value)) {
224-
zval_dtor(&new_zv);
224+
zval_ptr_dtor_nogc(&new_zv);
225225
return FAILURE;
226226
}
227227

@@ -251,7 +251,7 @@ static ZEND_INI_MH(ZaiConfigOnUpdateIni) {
251251
}
252252

253253
zai_config_replace_runtime_config(id, &new_zv);
254-
zval_dtor(&new_zv);
254+
zval_ptr_dtor_nogc(&new_zv);
255255
return SUCCESS;
256256
}
257257

zend_abstract_interface/interceptor/tests/resolver.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ INTERCEPTOR_TEST_CASE("runtime class_alias resolving", {
191191
INTERCEPTOR_TEST_CASE("ensure runtime post-declare resolving does not impact error", {
192192
int orig_resolved = zend_hash_num_elements(&zai_hook_resolved);
193193
INSTALL_CLASS_HOOK("Inherited", "bar");
194-
CALL_FN("failDeclare", REQUIRE(zval_is_true(&result)););
194+
CALL_FN("failDeclare", REQUIRE(zend_is_true(&result)););
195195
REQUIRE(zend_hash_num_elements(&zai_hook_resolved) == orig_resolved);
196196
});
197197
#endif

zend_abstract_interface/json/json.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ typedef unsigned char php_json_ctype;
44

55
typedef int php_json_error_code;
66

7+
#if PHP_VERSION_ID >= 80600
8+
typedef struct _php_json_error_location {
9+
size_t first_column;
10+
size_t first_line;
11+
size_t last_column;
12+
size_t last_line;
13+
} php_json_error_location;
14+
#endif
15+
716
typedef struct _php_json_scanner {
817
php_json_ctype *cursor; /* cursor position */
918
php_json_ctype *token; /* token position */
@@ -17,6 +26,9 @@ typedef struct _php_json_scanner {
1726
int state; /* condition state */
1827
int options; /* options */
1928
php_json_error_code errcode; /* error type if there is an error */
29+
#if PHP_VERSION_ID >= 80600
30+
php_json_error_location errloc; /* error location */
31+
#endif
2032
#if PHP_VERSION_ID >= 70200
2133
int utf8_invalid; /* whether utf8 is invalid */
2234
int utf8_invalid_count; /* number of extra character for invalid utf8 */
@@ -59,6 +71,9 @@ struct _php_json_parser {
5971
int depth;
6072
int max_depth;
6173
php_json_parser_methods methods;
74+
#if PHP_VERSION_ID >= 80600
75+
struct _php_json_parser_location *location;
76+
#endif
6277
};
6378

6479
#if PHP_VERSION_ID < 70100

zend_abstract_interface/sandbox/sandbox.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ void zai_sandbox_error_state_restore(zai_error_state *es);
157157
inline void zai_sandbox_exception_state_backup(zai_exception_state *es) {
158158
if (UNEXPECTED(EG(exception) != NULL)) {
159159
es->exception = EG(exception);
160-
es->prev_exception = EG(prev_exception);
161-
es->opline_before_exception = EG(opline_before_exception);
162160
EG(exception) = NULL;
161+
#if PHP_VERSION_ID < 80600
162+
es->prev_exception = EG(prev_exception);
163163
EG(prev_exception) = NULL;
164+
#endif
165+
es->opline_before_exception = EG(opline_before_exception);
164166
} else {
165167
es->exception = NULL;
166168
es->prev_exception = NULL;
@@ -174,7 +176,9 @@ inline void zai_sandbox_exception_state_restore(zai_exception_state *es) {
174176

175177
if (es->exception) {
176178
EG(exception) = es->exception;
179+
#if PHP_VERSION_ID < 80600
177180
EG(prev_exception) = es->prev_exception;
181+
#endif
178182
if (EG(current_execute_data)) {
179183
// ensure that we continue handling an exception if we were handling one before the sandbox call
180184
EG(current_execute_data)->opline = EG(exception_op);

0 commit comments

Comments
 (0)