1
0
mirror of https://github.com/php/pie.git synced 2026-03-23 23:12:17 +01:00

451: ensure Windows relative path expansion happens before creation of extension path

This commit is contained in:
James Titcumb
2025-12-16 18:37:17 +00:00
parent 81543dd72e
commit 702e0da43a

View File

@@ -107,18 +107,20 @@ class PhpBinaryPath
return $extensionPath;
}
// `extension_dir` may be a relative URL on Windows, so resolve it according to the location of PHP
if (self::operatingSystem() === OperatingSystem::Windows) {
$phpPath = dirname($this->phpBinaryPath);
$attemptExtensionPath = $phpPath . DIRECTORY_SEPARATOR . $extensionPath;
if (file_exists($attemptExtensionPath) && is_dir($attemptExtensionPath)) {
return $attemptExtensionPath;
}
}
// if the path is absolute, try to create it
if (mkdir($extensionPath, 0777, true) && file_exists($extensionPath) && is_dir($extensionPath)) {
return $extensionPath;
}
// `extension_dir` may be a relative URL on Windows, so resolve it according to the location of PHP
$phpPath = dirname($this->phpBinaryPath);
$attemptExtensionPath = $phpPath . DIRECTORY_SEPARATOR . $extensionPath;
if (file_exists($attemptExtensionPath) && is_dir($attemptExtensionPath)) {
return $attemptExtensionPath;
}
}
throw new RuntimeException('Could not determine extension path for ' . $this->phpBinaryPath);