Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some API change in 8.1.0alpha3 #1274

Merged
merged 2 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ext/php8/engine_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ struct ddtrace_error_handling {
int type;
int lineno;
zend_string *message;
#if PHP_VERSION_ID < 80100
char *file;
#else
zend_string *file;
#endif
int error_reporting;
zend_error_handling error_handling;
};
Expand Down Expand Up @@ -87,8 +91,13 @@ inline void ddtrace_sandbox_end(ddtrace_sandbox_backup *backup) {

PHP_FUNCTION(ddtrace_internal_function_handler);

#if PHP_VERSION_ID < 80100
#define DDTRACE_ERROR_CB_PARAMETERS \
int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message
#else
#define DDTRACE_ERROR_CB_PARAMETERS \
int orig_type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message
#endif

#define DDTRACE_ERROR_CB_PARAM_PASSTHRU orig_type, error_filename, error_lineno, message

Expand Down
23 changes: 23 additions & 0 deletions ext/php8/request_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ int dd_execute_php_file(const char *filename) {
zend_bool _original_cg_multibyte = CG(multibyte);
CG(multibyte) = FALSE;

#if PHP_VERSION_ID < 80100
ret = php_stream_open_for_zend_ex(filename, &file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE);
#else
zend_string *fn = zend_string_init(filename, filename_len, 0);
zend_stream_init_filename_ex(&file_handle, fn);
ret = php_stream_open_for_zend_ex(&file_handle, USE_PATH | STREAM_OPEN_FOR_INCLUDE);
zend_string_release(fn);
#endif

if (get_dd_trace_debug() && PG(last_error_message) && eh_stream.message != PG(last_error_message)) {
char *error;
Expand All @@ -56,7 +63,11 @@ int dd_execute_php_file(const char *filename) {
zend_destroy_file_handle(&file_handle);
} else {
new_op_array = NULL;
#if PHP_VERSION_ID < 80100
zend_file_handle_dtor(&file_handle);
#else
zend_destroy_file_handle(&file_handle);
#endif
}

zend_string_release(opened_path);
Expand Down Expand Up @@ -107,8 +118,14 @@ int dd_execute_auto_prepend_file(char *auto_prepend_file) {
// EG(current_execute_data) = ex->prev_execute_data;
memset(&prepend_file, 0, sizeof(zend_file_handle));
prepend_file.type = ZEND_HANDLE_FILENAME;
#if PHP_VERSION_ID < 80100
prepend_file.filename = auto_prepend_file;
int ret = zend_execute_scripts(ZEND_REQUIRE, NULL, 1, &prepend_file) == SUCCESS;
#else
prepend_file.filename = zend_string_init(auto_prepend_file, strlen(auto_prepend_file), 0);
int ret = zend_execute_scripts(ZEND_REQUIRE, NULL, 1, &prepend_file) == SUCCESS;
zend_string_release(prepend_file.filename);
#endif
// Exit no longer calls zend_bailout in PHP 8, so we need to "rethrow" the exit
if (ret == 0) {
zend_throw_unwind_exit();
Expand All @@ -126,7 +143,13 @@ void dd_request_init_hook_rinit(void) {
}

zval exists_flag;
#if PHP_VERSION_ID < 80100
php_stat(DDTRACE_G(request_init_hook), strlen(DDTRACE_G(request_init_hook)), FS_EXISTS, &exists_flag);
#else
zend_string *hook = zend_string_init(DDTRACE_G(request_init_hook), strlen(DDTRACE_G(request_init_hook)), 0);
php_stat(hook, FS_EXISTS, &exists_flag);
zend_string_release(hook);
#endif
if (Z_TYPE(exists_flag) == IS_FALSE) {
ddtrace_log_debugf("Cannot open request init hook; file does not exist: '%s'", DDTRACE_G(request_init_hook));
return;
Expand Down
4 changes: 4 additions & 0 deletions zend_abstract_interface/sandbox/sandbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ typedef struct zai_error_state_s {
int type;
int lineno;
zend_string *message;
#if PHP_VERSION_ID < 80100
char *file;
#else
zend_string *file;
#endif
int error_reporting;
zend_error_handling error_handling;
} zai_error_state;
Expand Down