Skip to content

Commit 45e90ee

Browse files
authored
Merge pull request #248 from dsavina/feature/override-default-ini
Allow overriding default INI values in extensions
2 parents 8078263 + 002fa49 commit 45e90ee

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

build-and-test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ set -e
183183
# Let's check that the "xdebug.client_host" contains a value different from "no value"
184184
docker run --rm -e PHP_EXTENSION_XDEBUG=1 thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT} php -i | grep xdebug.client_host| grep -v "no value"
185185

186+
# Let's check that "xdebug.mode" is set to "debug" by default
187+
docker run --rm -e PHP_EXTENSION_XDEBUG=1 thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT} php -i | grep xdebug.mode| grep "debug"
188+
189+
# Let's check that "xdebug.mode" is properly overridden
190+
docker run --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_INI_XDEBUG__MODE=debug,coverage thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT} php -i | grep xdebug.mode| grep "debug,coverage"
191+
186192
if [[ "${PHP_VERSION}" != "7.4" ]] && [[ "${PHP_VERSION}" != "8.0" ]]; then
187193
# Tests that blackfire + xdebug will output an error
188194
RESULT=`docker run --rm -e PHP_EXTENSION_XDEBUG=1 -e PHP_EXTENSION_BLACKFIRE=1 thecodingmachine/php:${PHP_VERSION}-${BRANCH}-${BRANCH_VARIANT} php -v 2>&1 | grep 'WARNING: Both Blackfire and Xdebug are enabled. This is not recommended as the PHP engine may not behave as expected. You should strongly consider disabling Xdebug or Blackfire.'`

utils/generate_conf.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@
88

99
// Reading environment variables from $_SERVER (because $_ENV is not necessarily populated, depending on variables_order directive):
1010

11-
foreach ($_SERVER as $key => $value) {
12-
if (strpos($key, 'PHP_INI_') === 0) {
13-
$iniParam = substr($key, 8);
14-
if ($iniParam !== 'SMTP') {
15-
// SMTP is the only php.ini parameter that contains uppercase letters (!)
16-
$iniParam = strtolower($iniParam);
17-
}
18-
$iniParam = str_replace('__', '.', $iniParam);
19-
// Let's protect the value if this is a string.
20-
if (!is_numeric($value) && $iniParam !== 'error_reporting') {
21-
$value = '"'.str_replace('"', '\\"', $value).'"';
22-
}
23-
echo "$iniParam=$value\n";
24-
}
25-
}
26-
2711
if (enableExtension('xdebug')) {
2812
//echo "zend_extension=xdebug.so\n";
2913
echo "xdebug.client_host=".getenv('XDEBUG_CLIENT_HOST')."\n";
@@ -40,3 +24,19 @@
4024
//echo "extension=blackfire.so\n";
4125
echo "blackfire.agent_socket=tcp://$blackFireAgent:8707\n";
4226
}
27+
28+
foreach ($_SERVER as $key => $value) {
29+
if (strpos($key, 'PHP_INI_') === 0) {
30+
$iniParam = substr($key, 8);
31+
if ($iniParam !== 'SMTP') {
32+
// SMTP is the only php.ini parameter that contains uppercase letters (!)
33+
$iniParam = strtolower($iniParam);
34+
}
35+
$iniParam = str_replace('__', '.', $iniParam);
36+
// Let's protect the value if this is a string.
37+
if (!is_numeric($value) && $iniParam !== 'error_reporting') {
38+
$value = '"'.str_replace('"', '\\"', $value).'"';
39+
}
40+
echo "$iniParam=$value\n";
41+
}
42+
}

0 commit comments

Comments
 (0)