Skip to content

Commit c0136f0

Browse files
authored
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] <#9196>
1 parent aafcf99 commit c0136f0

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ext/com_dotnet/tests/bug77578.phpt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,33 @@ com_dotnet
66
<?php
77
// To actually be able to verify the crash during shutdown on Windows, we have
88
// to execute a PHP subprocess, and check its exit status.
9+
10+
// First we determine whether com_dotnet would be loaded in the subprocess
911
$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
10-
$extension_dir = escapeshellarg(ini_get("extension_dir"));
1112
$script = <<<SCRIPT
12-
if (!extension_loaded('com_dotnet')) dl('com_dotnet');
13+
echo extension_loaded('com_dotnet') ? 'yes' : 'no';
14+
SCRIPT;
15+
exec("$php -r \"$script\"", $output);
16+
var_dump(isset($output[0]));
17+
$loaded = $output[0] === "yes";
18+
$output = null;
19+
20+
// Then we run the subprocess with com_dotnet loaded
21+
$script = <<<SCRIPT
1322
ini_set('com.autoregister_typelib', '1');
1423
new COM('WbemScripting.SWbemLocator');
1524
SCRIPT;
16-
$command = "$php -d extension_dir=$extension_dir -r \"$script\"";
25+
if ($loaded) {
26+
$command = "$php -r \"$script\"";
27+
} else {
28+
$extension_dir = escapeshellarg(ini_get("extension_dir"));
29+
$command = "$php -d extension_dir=$extension_dir -d extension=com_dotnet -r \"$script\"";
30+
}
1731
exec($command, $output, $status);
1832
var_dump($output, $status);
1933
?>
2034
--EXPECT--
35+
bool(true)
2136
array(0) {
2237
}
2338
int(0)

0 commit comments

Comments
 (0)