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

Add ionCube to the list of incompatible extensions + add INI setting to ignore incompatible extensions #2858

Merged
merged 5 commits into from
Sep 19, 2024
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
1 change: 1 addition & 0 deletions ext/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 24 additions & 7 deletions ext/excluded_modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@
#include <ext/standard/php_versioning.h>

#include <components/log/log.h>
#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) {
iamluc marked this conversation as resolved.
Show resolved Hide resolved
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
@see: https://xdebug.org/docs/compat
*/
#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
/*
Expand All @@ -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;
}
Expand All @@ -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");
}
}
}
3 changes: 2 additions & 1 deletion tests/xdebug/2.7.2/self_disable_php_7.0.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 18 additions & 0 deletions tests/xdebug/2.9.2/force_inject.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
The tracer will ignore incompatible extensions
--SKIPIF--
<?php if (PHP_VERSION_ID < 70100) die('skip: PHP 7.1+ required'); ?>
--INI--
xdebug.remote_enable=1
datadog.inject_force=1
datadog.trace.log_level=warn
--FILE--
<?php
if (!extension_loaded('Xdebug') || version_compare(phpversion('Xdebug'), '2.9.5') >= 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.
3 changes: 2 additions & 1 deletion tests/xdebug/2.9.2/self_disable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion tests/xdebug/2.9.2/startup_logging_diagnostics.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading