Skip to content

Commit

Permalink
Fix bad hasThis() check on PHP 7.0 (#2911)
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi authored Oct 23, 2024
1 parent 6d97821 commit 093ef34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
4 changes: 4 additions & 0 deletions ext/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,11 @@ static zend_always_inline zend_result zend_call_function_with_return_value(zend_
#undef ZEND_RAW_FENTRY
#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags, ...) { zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_internal_arg_info)-1), flags },

#if PHP_VERSION_ID < 70100
#define hasThis() (Z_OBJ_P(ZEND_THIS) != NULL)
#else
#define hasThis() (Z_TYPE_P(ZEND_THIS) == IS_OBJECT)
#endif
#endif

#endif // DD_COMPATIBILITY_H
4 changes: 2 additions & 2 deletions ext/live_debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static void dd_log_probe_capture_snapshot(ddog_DebuggerCapture *capture, dd_log_
}
if (hasThis()) {
struct ddog_CaptureValue capture_value = {0};
ddtrace_create_capture_value(&EX(This), &capture_value, capture_config, capture_config->max_reference_depth);
ddtrace_create_capture_value(getThis(), &capture_value, capture_config, capture_config->max_reference_depth);
ddog_snapshot_add_field(capture, DDOG_FIELD_TYPE_ARG, DDOG_CHARSLICE_C("this"), capture_value);
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ static void dd_log_probe_end(zend_ulong invocation, zend_execute_data *execute_d
dd_log_probe_capture_snapshot(capture, def, execute_data);
const ddog_CaptureConfiguration *capture_config = def->parent.probe.probe.log.capture;
struct ddog_CaptureValue capture_value = {0};
ddtrace_create_capture_value(&EX(This), &capture_value, capture_config, capture_config->max_reference_depth);
ddtrace_create_capture_value(retval, &capture_value, capture_config, capture_config->max_reference_depth);
ddog_snapshot_add_field(capture, DDOG_FIELD_TYPE_ARG, DDOG_CHARSLICE_C("@return"), capture_value);
}
ddtrace_sidecar_send_debugger_datum(dyn->payload);
Expand Down
29 changes: 3 additions & 26 deletions tests/ext/live-debugger/debugger_log_probe.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,9 @@ array(5) {
["@return"]=>
array(2) {
["type"]=>
string(3) "Bar"
["fields"]=>
array(1) {
["prop"]=>
array(2) {
["type"]=>
string(5) "array"
["elements"]=>
array(2) {
[0]=>
array(2) {
["type"]=>
string(3) "int"
["value"]=>
string(1) "1"
}
[1]=>
array(2) {
["type"]=>
string(3) "int"
["value"]=>
string(1) "2"
}
}
}
}
string(3) "int"
["value"]=>
string(2) "30"
}
["arg1"]=>
array(2) {
Expand Down

0 comments on commit 093ef34

Please sign in to comment.