Skip to content

Commit

Permalink
Improve extension matching in installer (#1851)
Browse files Browse the repository at this point in the history
* Improve extension matching in installer

As suggested in #1846.

* Add examples what shall be matched
  • Loading branch information
bwoebi authored Jan 12, 2023
1 parent c84dfa1 commit 06d3dad
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions datadog-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ function install($options)
foreach (scandir($phpProperties[INI_SCANDIR]) as $ini) {
$path = "{$phpProperties[INI_SCANDIR]}/$ini";
if (is_file($path)) {
if (preg_match('(^\s*extension\s*=.+ddtrace\.so)m', file_get_contents($path))) {
$iniFileName = $ini;
// match /path/to/ddtrace.so, plain extension = ddtrace or future extensions like ddtrace.dll
if (preg_match("(^\s*extension\s*=\s*(\S*ddtrace)\b)m", file_get_contents($path), $res)) {
if (basename($res[1]) == "ddtrace") {
$iniFileName = $ini;
}
}
}
}
Expand Down

0 comments on commit 06d3dad

Please sign in to comment.