-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I'am using php in a standard docker container FROM php:7.4-fpm which is compiled with --with-config-file-scan-dir
root@dev-6b74fdbbb-gwbnb:/var/www# php -i | grep scan
Configure Command => './configure' '--build=x86_64-linux-gnu' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--with-pic' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-pear' '--with-libdir=lib/x86_64-linux-gnu' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--disable-cgi' 'build_alias=x86_64-linux-gnu'
This leads to duplicate module loading when the temporary INI-File is generated from php_ini_scanned_files()
xdebug-handler/src/XdebugHandler.php
Line 197 in 84674dd
| if ($scanned = php_ini_scanned_files()) { |
I propose that the proc_open call should be provided with the PHP_INI_SCAN_DIR environment variable pointing to an directory containing an empty ini-file to resolve this issue:
$process = proc_open($cmd, array(), $pipes,null,['PHP_INI_SCAN_DIR' => '/tmp/test-scan-dir']);
xdebug-handler/src/XdebugHandler.php
Line 301 in 84674dd
| $process = proc_open($cmd, array(), $pipes); |
root@dev-6b74fdbbb-gwbnb:/var/www# ls /tmp/test-scan-dir/ -la
total 24
drwxr-xr-x 2 root root 4096 Oct 20 15:38 .
drwxrwxrwt 1 root root 20480 Oct 20 17:46 ..
-rw-r--r-- 1 root root 0 Oct 20 15:38 empty.ini
root@dev-6b74fdbbb-gwbnb:/var/www# cat /tmp/test-scan-dir/empty.ini
Note the comment in the PHP Manual:
https://www.php.net/manual/en/configuration.file.php#configuration.file.scan
If a blank directory is given in PHP_INI_SCAN_DIR, PHP will also scan the directory given at compile time via --with-config-file-scan-dir.
Alternatively the temporary INI-File could be stored in a directory and included this why and not by using the -c-Flag:
xdebug-handler/src/XdebugHandler.php
Line 424 in 84674dd
| array_push($php, '-n', '-c', $this->tmpIni); |
I've encountered this issue in https://github.com/phpstan/phpstan.