1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Avoid dl() in bug77578.phpt (GH-16663)

Avoid dl() in bug77578.phpt

`dl()` has known issues regarding permanent strings[1], so we better
avoid it, even if that means that we need to spawn two sub-processes.

[1] <https://github.com/php/php-src/issues/9196>
This commit is contained in:
Christoph M. Becker
2024-11-01 22:13:02 +01:00
committed by GitHub
parent aafcf997f9
commit c0136f0cb9

View File

@@ -6,18 +6,33 @@ com_dotnet
<?php
// To actually be able to verify the crash during shutdown on Windows, we have
// to execute a PHP subprocess, and check its exit status.
// First we determine whether com_dotnet would be loaded in the subprocess
$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
$extension_dir = escapeshellarg(ini_get("extension_dir"));
$script = <<<SCRIPT
if (!extension_loaded('com_dotnet')) dl('com_dotnet');
echo extension_loaded('com_dotnet') ? 'yes' : 'no';
SCRIPT;
exec("$php -r \"$script\"", $output);
var_dump(isset($output[0]));
$loaded = $output[0] === "yes";
$output = null;
// Then we run the subprocess with com_dotnet loaded
$script = <<<SCRIPT
ini_set('com.autoregister_typelib', '1');
new COM('WbemScripting.SWbemLocator');
SCRIPT;
$command = "$php -d extension_dir=$extension_dir -r \"$script\"";
if ($loaded) {
$command = "$php -r \"$script\"";
} else {
$extension_dir = escapeshellarg(ini_get("extension_dir"));
$command = "$php -d extension_dir=$extension_dir -d extension=com_dotnet -r \"$script\"";
}
exec($command, $output, $status);
var_dump($output, $status);
?>
--EXPECT--
bool(true)
array(0) {
}
int(0)