diff --git a/ext/configuration.h b/ext/configuration.h index b9c531f611..440d6c3f60 100644 --- a/ext/configuration.h +++ b/ext/configuration.h @@ -226,6 +226,7 @@ enum ddtrace_sampling_rules_format { CONFIG(INT, DD_OPENAI_SPAN_CHAR_LIMIT, "128") \ CONFIG(DOUBLE, DD_OPENAI_SPAN_PROMPT_COMPLETION_SAMPLE_RATE, "1.0") \ CONFIG(DOUBLE, DD_OPENAI_LOG_PROMPT_COMPLETION_SAMPLE_RATE, "0.1") \ + CONFIG(BOOL, DD_INJECT_FORCE, "false", .ini_change = zai_config_system_ini_change) \ DD_INTEGRATIONS #ifndef _WIN32 diff --git a/ext/excluded_modules.c b/ext/excluded_modules.c index 0caaa3d227..4bad02a804 100644 --- a/ext/excluded_modules.c +++ b/ext/excluded_modules.c @@ -6,8 +6,17 @@ #include #include +#include "configuration.h" bool ddtrace_is_excluded_module(zend_module_entry *module, char *error) { +#if PHP_VERSION_ID >= 80000 + if (strcmp("ionCube Loader", module->name) == 0) { + snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN, + "Found incompatible ionCube Loader extension"); + return true; + } +#endif + if (strcmp("xdebug", module->name) == 0) { /* PHP 7.0 was only supported from Xdebug 2.4 through 2.7 @@ -15,7 +24,7 @@ bool ddtrace_is_excluded_module(zend_module_entry *module, char *error) { */ #if PHP_VERSION_ID < 70100 snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN, - "Found incompatible Xdebug version %s; disabling conflicting functionality", module->version); + "Found incompatible Xdebug version %s", module->version); return true; #endif /* @@ -37,8 +46,7 @@ bool ddtrace_is_excluded_module(zend_module_entry *module, char *error) { int compare = php_version_compare(module->version, "2.9.5"); if (compare == -1) { snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN, - "Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater; disabling " - "conflicting functionality", + "Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater", module->version); return true; } @@ -50,18 +58,27 @@ void ddtrace_excluded_modules_startup() { zend_module_entry *module; ddtrace_has_excluded_module = false; + bool inject_force = get_global_DD_INJECT_FORCE(); ZEND_HASH_FOREACH_PTR(&module_registry, module) { char error[DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN + 1]; if (module && module->name && module->version && ddtrace_is_excluded_module(module, error)) { ddtrace_has_excluded_module = true; - if (strcmp("xdebug", module->name) == 0) { - LOG(ERROR, error); - } else { + if (inject_force) { LOG(WARN, error); + } else { + LOG(ERROR, error); } - return; } } ZEND_HASH_FOREACH_END(); + + if (ddtrace_has_excluded_module) { + if (inject_force) { + LOG(WARN, "Found incompatible extension(s); ignoring since 'datadog.inject_force' is enabled"); + ddtrace_has_excluded_module = false; + } else { + LOG(ERROR, "Found incompatible extension(s); disabling conflicting functionality"); + } + } } diff --git a/tests/xdebug/2.7.2/self_disable_php_7.0.phpt b/tests/xdebug/2.7.2/self_disable_php_7.0.phpt index ca2cae91ad..d8a32bbac1 100644 --- a/tests/xdebug/2.7.2/self_disable_php_7.0.phpt +++ b/tests/xdebug/2.7.2/self_disable_php_7.0.phpt @@ -11,5 +11,6 @@ if (!extension_loaded('Xdebug')) die('skip: Xdebug required'); echo 'Done.' . PHP_EOL; ?> --EXPECTF-- -[ddtrace] [error] Found incompatible Xdebug version %s; disabling conflicting functionality +[ddtrace] [error] Found incompatible Xdebug version %s +[ddtrace] [error] Found incompatible extension(s); disabling conflicting functionality Done. diff --git a/tests/xdebug/2.9.2/force_inject.phpt b/tests/xdebug/2.9.2/force_inject.phpt new file mode 100644 index 0000000000..b735f5fe22 --- /dev/null +++ b/tests/xdebug/2.9.2/force_inject.phpt @@ -0,0 +1,18 @@ +--TEST-- +The tracer will ignore incompatible extensions +--SKIPIF-- + +--INI-- +xdebug.remote_enable=1 +datadog.inject_force=1 +datadog.trace.log_level=warn +--FILE-- += 0) die('Xdebug < 2.9.5 required'); + +echo 'Done.' . PHP_EOL; +?> +--EXPECTF-- +[ddtrace] [warning] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater +[ddtrace] [warning] Found incompatible extension(s); ignoring since 'datadog.inject_force' is enabled +Done. diff --git a/tests/xdebug/2.9.2/self_disable.phpt b/tests/xdebug/2.9.2/self_disable.phpt index b40eaaf1ad..a6fe0fae32 100644 --- a/tests/xdebug/2.9.2/self_disable.phpt +++ b/tests/xdebug/2.9.2/self_disable.phpt @@ -11,5 +11,6 @@ if (!extension_loaded('Xdebug') || version_compare(phpversion('Xdebug'), '2.9.5' echo 'Done.' . PHP_EOL; ?> --EXPECTF-- -[ddtrace] [error] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater; disabling conflicting functionality +[ddtrace] [error] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater +[ddtrace] [error] Found incompatible extension(s); disabling conflicting functionality Done. diff --git a/tests/xdebug/2.9.2/startup_logging_diagnostics.phpt b/tests/xdebug/2.9.2/startup_logging_diagnostics.phpt index 27599a5ff3..f639637a3e 100644 --- a/tests/xdebug/2.9.2/startup_logging_diagnostics.phpt +++ b/tests/xdebug/2.9.2/startup_logging_diagnostics.phpt @@ -18,4 +18,4 @@ if (!isset($logs['incompatible module xdebug'])) { echo 'Log: ' . $logs['incompatible module xdebug'] . PHP_EOL; ?> --EXPECT-- -Log: Found incompatible Xdebug version 2.9.2; ddtrace requires Xdebug 2.9.5 or greater; disabling conflicting functionality +Log: Found incompatible Xdebug version 2.9.2; ddtrace requires Xdebug 2.9.5 or greater