Skip to content

Commit 3746a2f

Browse files
iamlucbwoebi
andauthored
Add ionCube to the list of incompatible extensions + add INI setting to ignore incompatible extensions (#2858)
* Add ionCube to the list of incompatible extensions * Add 'datadog.inject_force' INI setting to ignore incompatible extensions * Conflict with ionCube only on PHP 8.0+ * Fix access of global config Co-authored-by: Bob Weinand <[email protected]> * Fix ini_change mode Co-authored-by: Bob Weinand <[email protected]> --------- Co-authored-by: Bob Weinand <[email protected]>
1 parent 7088a2d commit 3746a2f

6 files changed

Lines changed: 48 additions & 10 deletions

File tree

ext/configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ enum ddtrace_sampling_rules_format {
227227
CONFIG(INT, DD_OPENAI_SPAN_CHAR_LIMIT, "128") \
228228
CONFIG(DOUBLE, DD_OPENAI_SPAN_PROMPT_COMPLETION_SAMPLE_RATE, "1.0") \
229229
CONFIG(DOUBLE, DD_OPENAI_LOG_PROMPT_COMPLETION_SAMPLE_RATE, "0.1") \
230+
CONFIG(BOOL, DD_INJECT_FORCE, "false", .ini_change = zai_config_system_ini_change) \
230231
DD_INTEGRATIONS
231232

232233
#ifndef _WIN32

ext/excluded_modules.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
#include <ext/standard/php_versioning.h>
77

88
#include <components/log/log.h>
9+
#include "configuration.h"
910

1011
bool ddtrace_is_excluded_module(zend_module_entry *module, char *error) {
12+
#if PHP_VERSION_ID >= 80000
13+
if (strcmp("ionCube Loader", module->name) == 0) {
14+
snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN,
15+
"Found incompatible ionCube Loader extension");
16+
return true;
17+
}
18+
#endif
19+
1120
if (strcmp("xdebug", module->name) == 0) {
1221
/*
1322
PHP 7.0 was only supported from Xdebug 2.4 through 2.7
1423
@see: https://xdebug.org/docs/compat
1524
*/
1625
#if PHP_VERSION_ID < 70100
1726
snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN,
18-
"Found incompatible Xdebug version %s; disabling conflicting functionality", module->version);
27+
"Found incompatible Xdebug version %s", module->version);
1928
return true;
2029
#endif
2130
/*
@@ -37,8 +46,7 @@ bool ddtrace_is_excluded_module(zend_module_entry *module, char *error) {
3746
int compare = php_version_compare(module->version, "2.9.5");
3847
if (compare == -1) {
3948
snprintf(error, DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN,
40-
"Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater; disabling "
41-
"conflicting functionality",
49+
"Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater",
4250
module->version);
4351
return true;
4452
}
@@ -50,18 +58,27 @@ void ddtrace_excluded_modules_startup() {
5058
zend_module_entry *module;
5159

5260
ddtrace_has_excluded_module = false;
61+
bool inject_force = get_global_DD_INJECT_FORCE();
5362

5463
ZEND_HASH_FOREACH_PTR(&module_registry, module) {
5564
char error[DDTRACE_EXCLUDED_MODULES_ERROR_MAX_LEN + 1];
5665
if (module && module->name && module->version && ddtrace_is_excluded_module(module, error)) {
5766
ddtrace_has_excluded_module = true;
58-
if (strcmp("xdebug", module->name) == 0) {
59-
LOG(ERROR, error);
60-
} else {
67+
if (inject_force) {
6168
LOG(WARN, error);
69+
} else {
70+
LOG(ERROR, error);
6271
}
63-
return;
6472
}
6573
}
6674
ZEND_HASH_FOREACH_END();
75+
76+
if (ddtrace_has_excluded_module) {
77+
if (inject_force) {
78+
LOG(WARN, "Found incompatible extension(s); ignoring since 'datadog.inject_force' is enabled");
79+
ddtrace_has_excluded_module = false;
80+
} else {
81+
LOG(ERROR, "Found incompatible extension(s); disabling conflicting functionality");
82+
}
83+
}
6784
}

tests/xdebug/2.7.2/self_disable_php_7.0.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ if (!extension_loaded('Xdebug')) die('skip: Xdebug required');
1111
echo 'Done.' . PHP_EOL;
1212
?>
1313
--EXPECTF--
14-
[ddtrace] [error] Found incompatible Xdebug version %s; disabling conflicting functionality
14+
[ddtrace] [error] Found incompatible Xdebug version %s
15+
[ddtrace] [error] Found incompatible extension(s); disabling conflicting functionality
1516
Done.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
The tracer will ignore incompatible extensions
3+
--SKIPIF--
4+
<?php if (PHP_VERSION_ID < 70100) die('skip: PHP 7.1+ required'); ?>
5+
--INI--
6+
xdebug.remote_enable=1
7+
datadog.inject_force=1
8+
datadog.trace.log_level=warn
9+
--FILE--
10+
<?php
11+
if (!extension_loaded('Xdebug') || version_compare(phpversion('Xdebug'), '2.9.5') >= 0) die('Xdebug < 2.9.5 required');
12+
13+
echo 'Done.' . PHP_EOL;
14+
?>
15+
--EXPECTF--
16+
[ddtrace] [warning] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater
17+
[ddtrace] [warning] Found incompatible extension(s); ignoring since 'datadog.inject_force' is enabled
18+
Done.

tests/xdebug/2.9.2/self_disable.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ if (!extension_loaded('Xdebug') || version_compare(phpversion('Xdebug'), '2.9.5'
1111
echo 'Done.' . PHP_EOL;
1212
?>
1313
--EXPECTF--
14-
[ddtrace] [error] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater; disabling conflicting functionality
14+
[ddtrace] [error] Found incompatible Xdebug version %s; ddtrace requires Xdebug 2.9.5 or greater
15+
[ddtrace] [error] Found incompatible extension(s); disabling conflicting functionality
1516
Done.

tests/xdebug/2.9.2/startup_logging_diagnostics.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ if (!isset($logs['incompatible module xdebug'])) {
1818
echo 'Log: ' . $logs['incompatible module xdebug'] . PHP_EOL;
1919
?>
2020
--EXPECT--
21-
Log: Found incompatible Xdebug version 2.9.2; ddtrace requires Xdebug 2.9.5 or greater; disabling conflicting functionality
21+
Log: Found incompatible Xdebug version 2.9.2; ddtrace requires Xdebug 2.9.5 or greater

0 commit comments

Comments
 (0)