Skip to content

Commit 52362a0

Browse files
committed
dedup loaded ext names remap
1 parent c187255 commit 52362a0

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

run-tests.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -880,24 +880,19 @@ function write_information(): void
880880
// load list of enabled and loadable extensions
881881
save_text($info_file, <<<'PHP'
882882
<?php
883-
$exts = [];
884-
foreach (get_loaded_extensions() as $ext) {
885-
$exts[] = ['Zend OPcache' => 'opcache'][$ext] ?? $ext;
886-
}
883+
$exts = get_loaded_extensions();
887884
$ext_dir = ini_get('extension_dir');
888885
foreach (scandir($ext_dir) as $file) {
889-
if (!preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
890-
continue;
891-
}
892-
$ext = $matches[1];
893-
if (!in_array($ext, $exts) && !extension_loaded($ext) && @dl($file)) {
894-
$exts[] = $ext;
886+
if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
887+
if (@dl($matches[1])) {
888+
$exts[] = $matches[1];
889+
}
895890
}
896891
}
897892
echo implode(',', $exts);
898-
?>
899-
PHP);
900-
$exts_to_test = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""));
893+
PHP);
894+
$extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""));
895+
$exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames));
901896
// check for extensions that need special handling and regenerate
902897
$info_params_ex = [
903898
'session' => ['session.auto_start=0'],
@@ -2784,6 +2779,22 @@ function run_test(string $php, $file, array $env): string
27842779
return $restype[0] . 'ED';
27852780
}
27862781

2782+
/**
2783+
* Map "Zend OPcache" to "opcache" and convert all ext names to lowercase.
2784+
*/
2785+
function remap_loaded_extensions_names(array $names): array
2786+
{
2787+
$exts = [];
2788+
foreach ($names as $name) {
2789+
if ($name === 'Core') {
2790+
continue;
2791+
}
2792+
$exts[] = ['Zend OPcache' => 'opcache'][$name] ?? strtolower($name);
2793+
}
2794+
2795+
return $exts;
2796+
}
2797+
27872798
/**
27882799
* @return bool|int
27892800
*/
@@ -3674,11 +3685,8 @@ public function getExtensions(string $php): array
36743685
}
36753686

36763687
$extDir = shell_exec("$php -d display_errors=0 -r \"echo ini_get('extension_dir');\"");
3677-
$extensions = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
3678-
$extensions = array_map('strtolower', $extensions);
3679-
if (in_array('zend opcache', $extensions)) {
3680-
$extensions[] = 'opcache';
3681-
}
3688+
$extensionsNames = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
3689+
$extensions = remap_loaded_extensions_names($extensionsNames);
36823690

36833691
$result = [$extDir, $extensions];
36843692
$this->extensions[$php] = $result;

0 commit comments

Comments
 (0)