Skip to content

Commit af34b86

Browse files
committed
fix: require only core PHP DLLs in Windows CLI fixtures
The Windows integration fixture treated every php[0-9]*.dll shipped in the release ZIP as a module that each CLI worker must load. This included php8phpdbg.dll, so discovery timed out even though both PHP executables and their php8.dll core modules were correctly detected. Restrict expected CLI modules to core php<major>.dll and php<major>ts.dll names. Continue copying release dependencies for execution and retain checks for both independent CLI installations. Leave auditor discovery, verdicts and Windows loaded-image uncertainty unchanged. Add a regression that builds both non-thread-safe and thread-safe fixture inventories with debugger and Apache DLLs present. It reproduces the original over-inclusive inventory without executing or installing PHP. Validation: the regression failed before the fix and all 114 local tests pass afterward. The corrected hosted Windows integration run is pending.
1 parent 641103f commit af34b86

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎test_workflow.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ def test_php_fixture_refuses_workstations_and_self_hosted_runners(self):
2424
self.assertRaisesRegex(RuntimeError, "Run only inside disposable"):
2525
verify_php.main()
2626

27+
def test_windows_php_fixture_requires_core_dll_but_not_debugger_dll(self):
28+
import verify_php
29+
for core in ("php8.dll", "php8ts.dll"):
30+
with self.subTest(core=core), tempfile.TemporaryDirectory() as directory:
31+
root = Path(directory)
32+
for name in ("php.exe", core, "php8phpdbg.dll", "php8apache2_4.dll"):
33+
(root / name).write_bytes(b"fixture")
34+
with patch.dict(os.environ, {"GITHUB_ACTIONS": "true", "RUNNER_ENVIRONMENT": "github-hosted"}), \
35+
patch.object(verify_php.sys, "platform", "win32"), \
36+
patch.object(verify_php.sys, "argv", ["verify_php.py", "--php", str(root / "php.exe"),
37+
"--version", "8.3.36", "--source", "fixture"]), \
38+
patch.object(verify_php.subprocess, "run") as execute, \
39+
patch.object(verify_php.subprocess, "Popen") as start, \
40+
patch.object(verify_php.audit, "discover", side_effect=RuntimeError("inventory captured")) as discover:
41+
execute.return_value.stdout = "8.3.36"
42+
start.return_value.poll.return_value = None
43+
with self.assertRaisesRegex(RuntimeError, "inventory captured"):
44+
verify_php.main()
45+
runtimes = discover.call_args.args[0]["runtimes"]
46+
self.assertEqual(len(runtimes), 4)
47+
self.assertEqual(sorted((Path(row["path"]).name, row["kind"]) for row in runtimes),
48+
sorted([("php.exe", "php"), (core, "mod_php")] * 2))
49+
self.assertEqual(len({row["path"] for row in runtimes}), 4)
50+
2751
def test_real_file_inspection_keeps_permission_errors_distinct_from_missing_paths(self):
2852
path = str(Path(tempfile.gettempdir()) / "php-fixture")
2953
with patch.object(audit.os, "stat", side_effect=PermissionError("denied")):

‎verify_php.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import importlib.util
55
import json
66
import os
7+
import re
78
import shutil
89
import subprocess
910
import sys
@@ -92,7 +93,9 @@ def main():
9293
if sys.platform == "win32":
9394
for parent in (php.parent, root):
9495
for library in parent.glob("php[0-9]*.dll"):
95-
paths[str(library)] = "mod_php"
96+
# CLI workers load the core DLL, not debugger or Apache DLLs.
97+
if re.fullmatch(r"php[0-9]+(?:ts)?\.dll", library.name, re.I):
98+
paths[str(library)] = "mod_php"
9699
config = {"schema": 1, "scope": "disposable real-PHP fixtures", "coverage_confirmed": True,
97100
"runtimes": [{"label": path, "path": path, "kind": kind} for path, kind in paths.items()]}
98101
builds = {audit.hash_file(path)["sha256"]: args.version for path in paths}

0 commit comments

Comments
 (0)