@@ -306,7 +306,10 @@ function main(): void
306306 'date.timezone=UTC ' ,
307307 ];
308308
309- $ no_file_cache = '-d opcache.file_cache= -d opcache.file_cache_only=0 ' ;
309+ $ no_file_cache = [
310+ '-d ' , 'opcache.file_cache= ' ,
311+ '-d ' , 'opcache.file_cache_only=0 ' ,
312+ ];
310313
311314 // Determine the tests to be run.
312315
@@ -822,6 +825,7 @@ function write_information(array $user_tests, $phpdbg): void
822825 global $ php , $ php_cgi , $ php_info , $ ini_overwrites , $ pass_option_args , $ exts_to_test , $ valgrind , $ no_file_cache ;
823826 $ php_escaped = escapeshellarg ($ php );
824827 $ escaped_pass_options = escaped_shell_string_from ($ pass_option_args );
828+ $ escaped_no_file_cache = escaped_shell_string_from ($ no_file_cache );
825829
826830 // Get info from php
827831 $ info_file = __DIR__ . '/run-test-info.php ' ;
@@ -837,12 +841,12 @@ function write_information(array $user_tests, $phpdbg): void
837841 $ info_params = [];
838842 settings2array ($ ini_overwrites , $ info_params );
839843 $ info_params = settings2params ($ info_params );
840- $ php_info = shell_exec ("$ php_escaped $ escaped_pass_options $ info_params $ no_file_cache \"$ info_file \"" );
844+ $ php_info = shell_exec ("$ php_escaped $ escaped_pass_options $ info_params $ escaped_no_file_cache \"$ info_file \"" );
841845 define ('TESTED_PHP_VERSION ' , shell_exec ("$ php_escaped -n -r \"echo PHP_VERSION; \"" ));
842846
843847 if ($ php_cgi && $ php != $ php_cgi ) {
844848 $ php_cgi_escaped = escapeshellarg ($ php_cgi );
845- $ php_info_cgi = shell_exec ("$ php_cgi_escaped $ escaped_pass_options $ info_params $ no_file_cache -q \"$ info_file \"" );
849+ $ php_info_cgi = shell_exec ("$ php_cgi_escaped $ escaped_pass_options $ info_params $ escaped_no_file_cache -q \"$ info_file \"" );
846850 $ php_info_sep = "\n--------------------------------------------------------------------- " ;
847851 $ php_cgi_info = "$ php_info_sep \nPHP : $ php_cgi $ php_info_cgi$ php_info_sep " ;
848852 } else {
@@ -851,7 +855,7 @@ function write_information(array $user_tests, $phpdbg): void
851855
852856 if ($ phpdbg ) {
853857 $ phpdbg_escaped = escapeshellarg ($ phpdbg );
854- $ phpdbg_info = shell_exec ("$ phpdbg_escaped $ escaped_pass_options $ info_params $ no_file_cache -qrr \"$ info_file \"" );
858+ $ phpdbg_info = shell_exec ("$ phpdbg_escaped $ escaped_pass_options $ info_params $ escaped_no_file_cache -qrr \"$ info_file \"" );
855859 $ php_info_sep = "\n--------------------------------------------------------------------- " ;
856860 $ phpdbg_info = "$ php_info_sep \nPHP : $ phpdbg $ phpdbg_info$ php_info_sep " ;
857861 } else {
@@ -877,7 +881,7 @@ function write_information(array $user_tests, $phpdbg): void
877881 }
878882 echo implode(',', $exts);
879883 PHP);
880- $ extensionsNames = explode (', ' , shell_exec ("$ php_escaped $ escaped_pass_options $ info_params $ no_file_cache \"$ info_file \"" ));
884+ $ extensionsNames = explode (', ' , shell_exec ("$ php_escaped $ escaped_pass_options $ info_params $ escaped_no_file_cache \"$ info_file \"" ));
881885 $ exts_to_test = array_unique (remap_loaded_extensions_names ($ extensionsNames ));
882886 // check for extensions that need special handling and regenerate
883887 $ info_params_ex = [
@@ -2099,13 +2103,16 @@ function run_test(string $php, $file, array $env): string
20992103 if ($ extensions != []) {
21002104 $ ext_params = [];
21012105 settings2array ($ ini_overwrites , $ ext_params );
2102- $ ext_params = settings2params ($ ext_params );
2103- $ extension_command = escaped_shell_string_from ([
2106+ $ ext_params = settings2arguments ($ ext_params );
2107+
2108+ [$ ext_dir , $ loaded ] = $ skipCache ->getExtensions ([
21042109 $ php ,
21052110 ...$ pass_option_args ,
21062111 ...$ extra_option_args ,
2107- ]) . " $ ext_params $ no_file_cache " ;
2108- [$ ext_dir , $ loaded ] = $ skipCache ->getExtensions ($ extension_command );
2112+ ...$ ext_params ,
2113+ ...$ no_file_cache ,
2114+ ]);
2115+
21092116 $ ext_prefix = IS_WINDOWS ? "php_ " : "" ;
21102117 $ missing = [];
21112118 foreach ($ extensions as $ req_ext ) {
@@ -3761,19 +3768,33 @@ public function checkSkip(array $command, string $code, string $checkFile, strin
37613768 return $ result ;
37623769 }
37633770
3764- public function getExtensions (string $ php ): array
3771+ public function getExtensions (array $ command ): array
37653772 {
3766- if (isset ($ this ->extensions [$ php ])) {
3773+ $ key = implode ("\0" , $ command );
3774+ if (isset ($ this ->extensions [$ key ])) {
37673775 $ this ->extHits ++;
3768- return $ this ->extensions [$ php ];
3776+ return $ this ->extensions [$ key ];
37693777 }
37703778
3771- $ extDir = shell_exec ("$ php -d display_errors=0 -r \"echo ini_get('extension_dir'); \"" );
3772- $ extensionsNames = explode (", " , shell_exec ("$ php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions()); \"" ));
3779+ $ output = shell_exec (escaped_shell_string_from ([
3780+ ...$ command ,
3781+ '-d ' ,
3782+ 'display_errors=0 ' ,
3783+ '-r ' ,
3784+ 'echo ini_get("extension_dir"), "\0", implode(",", get_loaded_extensions()); ' ,
3785+ ]));
3786+
3787+ if (!is_string ($ output ) || !str_contains ($ output , "\0" )) {
3788+ error ("Unable to query loaded PHP extensions. " );
3789+ }
3790+
3791+ [$ extDir , $ extensionsNames ] = explode ("\0" , $ output , 2 );
3792+
3793+ $ extensionsNames = explode (", " , $ extensionsNames );
37733794 $ extensions = remap_loaded_extensions_names ($ extensionsNames );
37743795
37753796 $ result = [$ extDir , $ extensions ];
3776- $ this ->extensions [$ php ] = $ result ;
3797+ $ this ->extensions [$ key ] = $ result ;
37773798 $ this ->extMisses ++;
37783799
37793800 return $ result ;
0 commit comments