Skip to content

Commit

Permalink
Fixed issue #2032: Use runtime PHP version instead of compiled-agains…
Browse files Browse the repository at this point in the history
…t version
  • Loading branch information
derickr committed Oct 8, 2021
1 parent ec4e5c3 commit 4ef0e54
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/base/base_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ typedef struct _xdebug_base_globals_t {
xdebug_llist *filters_code_coverage;
xdebug_llist *filters_stack;
xdebug_llist *filters_tracing;

/* PHP versions */
const char *php_version_compile_time;
const char *php_version_run_time;
} xdebug_base_globals_t;

typedef struct _xdebug_base_settings_t {
Expand Down
4 changes: 2 additions & 2 deletions src/debugger/handler_dbgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ DBGP_FUNC(feature_get)
XDEBUG_STR_CASE_END

XDEBUG_STR_CASE("language_version")
xdebug_xml_add_text(*retval, xdstrdup(PHP_VERSION));
xdebug_xml_add_text(*retval, xdstrdup(XG_BASE(php_version_run_time)));
xdebug_xml_add_attribute(*retval, "supported", "1");
XDEBUG_STR_CASE_END

Expand Down Expand Up @@ -2388,7 +2388,7 @@ int xdebug_dbgp_init(xdebug_con *context, int mode)
xdebug_xml_add_attribute_ex(response, "fileuri", xdebug_path_to_url(context->program_name), 0, 1);
}
xdebug_xml_add_attribute_ex(response, "language", "PHP", 0, 0);
xdebug_xml_add_attribute_ex(response, "xdebug:language_version", PHP_VERSION, 0, 0);
xdebug_xml_add_attribute_ex(response, "xdebug:language_version", XG_BASE(php_version_run_time), 0, 0);
xdebug_xml_add_attribute_ex(response, "protocol_version", DBGP_VERSION, 0, 0);
xdebug_xml_add_attribute_ex(response, "appid", xdebug_sprintf(ZEND_ULONG_FMT, xdebug_get_pid()), 0, 1);

Expand Down
3 changes: 2 additions & 1 deletion src/lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ static void xdebug_print_php_section(void)
php_info_print_table_colspan_header(2, (char*) "PHP");

php_info_print_table_colspan_header(2, (char*) "Build Configuration");
php_info_print_table_row(2, "Version", PHP_VERSION);
php_info_print_table_row(2, "Version (Run Time)", XG_BASE(php_version_run_time));
php_info_print_table_row(2, "Version (Compile Time)", XG_BASE(php_version_compile_time));
#if ZEND_DEBUG
php_info_print_table_row(2, "Debug Build", "yes");
#else
Expand Down
2 changes: 1 addition & 1 deletion src/profiler/profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void profiler_write_header(xdebug_file *file, char *script_name)
if (XINI_PROF(profiler_append)) {
xdebug_file_printf(file, "\n==== NEW PROFILING FILE ==============================================\n");
}
xdebug_file_printf(file, "version: 1\ncreator: xdebug %s (PHP %s)\n", XDEBUG_VERSION, PHP_VERSION);
xdebug_file_printf(file, "version: 1\ncreator: xdebug %s (PHP %s)\n", XDEBUG_VERSION, XG_BASE(php_version_run_time));
xdebug_file_printf(file, "cmd: %s\npart: 1\npositions: line\n\n", script_name);
xdebug_file_printf(file, "events: Time_(10ns) Memory_(bytes)\n\n");
xdebug_file_flush(file);
Expand Down
4 changes: 4 additions & 0 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,13 @@ static void xdebug_init_base_globals(xdebug_base_globals_t *xg)
xg->filters_stack = NULL;
xg->filters_tracing = NULL;

xg->php_version_compile_time = PHP_VERSION;
xg->php_version_run_time = zend_get_module_version("standard");

xdebug_nanotime_init(xg);
}


static void php_xdebug_init_globals(zend_xdebug_globals *xg)
{
memset(&xg->globals, 0, sizeof(xg->globals));
Expand Down

0 comments on commit 4ef0e54

Please sign in to comment.