8000 bug #27303 [Process] Consider "executable" suffixes first on Windows … · symfony/symfony@dc0ac87 · GitHub
[go: up one dir, main page]

Skip to content

Commit dc0ac87

Browse files
committed
bug #27303 [Process] Consider "executable" suffixes first on Windows (sanmai)
This PR was squashed before being merged into the 2.8 branch (closes #27303). Discussion ---------- [Process] Consider "executable" suffixes first on Windows | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | n/a Executable finder should consider "executable" suffixes first on Windows because we basically ignore executability on Windows (on the lines below changed), which leads, for example, to finding usually-non-executable `phpunit` file first where both `phpunit` and `phpunit.bat` are present. I may miss something here, so please tell me if this makes any sense. Same change against master: #27301 Commits ------- 9372e7a [Process] Consider \"executable\" suffixes first on Windows
2 parents 148e7ef + 9372e7a commit dc0ac87

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function find($name, $default = null, array $extraDirs = array())
7373
$suffixes = array('');
7474
if ('\\' === DIRECTORY_SEPARATOR) {
7575
$pathExt = getenv('PATHEXT');
76-
$suffixes = array_merge($suffixes, $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes);
76+
$suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
7777
}
7878
foreach ($suffixes as $suffix) {
7979
foreach ($dirs as $dir) {

src/Symfony/Component/Process/Tests/ExecutableFinderTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,36 @@ public function testFindProcessInOpenBasedir()
129129
$this->assertSamePath(PHP_BINARY, $result);
130130
}
131131

132+
/**
133+
* @requires PHP 5.4
134+
*/
135+
public function testFindBatchExecutableOnWindows()
136+
{
137+
if (ini_get('open_basedir')) {
138+
$this->markTestSkipped('Cannot test when open_basedir is set');
139+
}
140+
if ('\\' !== DIRECTORY_SEPARATOR) {
141+
$this->markTestSkipped('Can be only tested on windows');
142+
}
143+
144+
$target = tempnam(sys_get_temp_dir(), 'example-windows-executable');
145+
146+
touch($target);
147+
touch($target.'.BAT');
148+
149+
$this->assertFalse(is_executable($target));
150+
151+
$this->setPath(sys_get_temp_dir());
152+
153+
$finder = new ExecutableFinder();
154+
$result = $finder->find(basename($target), false);
155+
156+
unlink($target);
157+
unlink($target.'.BAT');
158+
159+
$this->assertSamePath($target.'.BAT', $result);
160+
}
161+
132162
private function assertSamePath($expected, $tested)
133163
{
134164
if ('\\' === DIRECTORY_SEPARATOR) {

0 commit comments

Comments
 (0)
0