Skip to content

Commit 2981278

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Make FormErrorIterator generic [symfony/mailjet-mailer] Fix invalid mailjet error managment typehint of DkimOptions algorithm wrong Remove extra space in NotificationEmail Fix the usage of the Valid constraints in array-based forms Fix return value of `NullToken::getUser()` [DI] fix `ServiceSubscriberTrait` bug where parent has `__call()` [HttpClient] Fix reading proxy settings from dotenv when curl is used [Process] Don't return executable directories in PhpExecutableFinder Center icons vertically in trace list
2 parents 1cccecc + ca5bdf2 commit 2981278

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

PhpExecutableFinder.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function find(bool $includeArgs = true): string|false
4343
}
4444
}
4545

46+
if (@is_dir($php)) {
47+
return false;
48+
}
49+
4650
return $php;
4751
}
4852

@@ -55,20 +59,20 @@ public function find(bool $includeArgs = true): string|false
5559
}
5660

5761
if ($php = getenv('PHP_PATH')) {
58-
if (!@is_executable($php)) {
62+
if (!@is_executable($php) || @is_dir($php)) {
5963
return false;
6064
}
6165

6266
return $php;
6367
}
6468

6569
if ($php = getenv('PHP_PEAR_PHP_BIN')) {
66-
if (@is_executable($php)) {
70+
if (@is_executable($php) && !@is_dir($php)) {
6771
return $php;
6872
}
6973
}
7074

71-
if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
75+
if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
7276
return $php;
7377
}
7478

Tests/PhpExecutableFinderTest.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,32 @@ public function testFindArguments()
5050
public function testNotExitsBinaryFile()
5151
{
5252
$f = new PhpExecutableFinder();
53-
$phpBinaryEnv = \PHP_BINARY;
54-
putenv('PHP_BINARY=/usr/local/php/bin/php-invalid');
5553

56-
$this->assertFalse($f->find(), '::find() returns false because of not exist file');
57-
$this->assertFalse($f->find(false), '::find(false) returns false because of not exist file');
54+
$originalPhpBinary = getenv('PHP_BINARY');
5855

59-
putenv('PHP_BINARY='.$phpBinaryEnv);
56+
try {
57+
putenv('PHP_BINARY=/usr/local/php/bin/php-invalid');
58+
59+
$this->assertFalse($f->find(), '::find() returns false because of not exist file');
60+
$this->assertFalse($f->find(false), '::find(false) returns false because of not exist file');
61+
} finally {
62+
putenv('PHP_BINARY='.$originalPhpBinary);
63+
}
64+
}
65+
66+
public function testFindWithExecutableDirectory()
67+
{
68+
$originalPhpBinary = getenv('PHP_BINARY');
69+
70+
try {
71+
$executableDirectoryPath = sys_get_temp_dir().'/PhpExecutableFinderTest_testFindWithExecutableDirectory';
72+
@mkdir($executableDirectoryPath);
73+
$this->assertTrue(is_executable($executableDirectoryPath));
74+
putenv('PHP_BINARY='.$executableDirectoryPath);
75+
76+
$this->assertFalse((new PhpExecutableFinder())->find());
77+
} finally {
78+
putenv('PHP_BINARY='.$originalPhpBinary);
79+
}
6080
}
6181
}

0 commit comments

Comments
 (0)