Skip to content

Commit 702e0da

Browse files
committed
451: ensure Windows relative path expansion happens before creation of extension path
1 parent 81543dd commit 702e0da

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Platform/TargetPhp/PhpBinaryPath.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,20 @@ public function extensionPath(): string
107107
return $extensionPath;
108108
}
109109

110+
// `extension_dir` may be a relative URL on Windows, so resolve it according to the location of PHP
111+
if (self::operatingSystem() === OperatingSystem::Windows) {
112+
$phpPath = dirname($this->phpBinaryPath);
113+
$attemptExtensionPath = $phpPath . DIRECTORY_SEPARATOR . $extensionPath;
114+
115+
if (file_exists($attemptExtensionPath) && is_dir($attemptExtensionPath)) {
116+
return $attemptExtensionPath;
117+
}
118+
}
119+
110120
// if the path is absolute, try to create it
111121
if (mkdir($extensionPath, 0777, true) && file_exists($extensionPath) && is_dir($extensionPath)) {
112122
return $extensionPath;
113123
}
114-
115-
// `extension_dir` may be a relative URL on Windows, so resolve it according to the location of PHP
116-
$phpPath = dirname($this->phpBinaryPath);
117-
$attemptExtensionPath = $phpPath . DIRECTORY_SEPARATOR . $extensionPath;
118-
119-
if (file_exists($attemptExtensionPath) && is_dir($attemptExtensionPath)) {
120-
return $attemptExtensionPath;
121-
}
122124
}
123125

124126
throw new RuntimeException('Could not determine extension path for ' . $this->phpBinaryPath);

0 commit comments

Comments
 (0)