bug #11425 Fix issue described in #11421 (Ben, ben-rosio)

This PR was merged into the 2.3 branch.

Discussion
----------

Fix issue described in #11421

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11421
| License       | MIT
| Doc PR        | NA

This pull request fixes the issue described in #11421.  It also adds a test for the issue.  The issue is present in 2.0 forward, but I decided to fix it on the 2.3 branch so that I could also write a test for it (2.0 had no tests for the Process component, and 2.1 and 2.2 didn't have tests for the `ExecutableFinder` class).

Commits
-------

4cf50e8 Bring code into standard
9f4313c [Process] Add test to verify fix for issue #11421
02eb765 [Process] Fixes issue #11421
This commit is contained in:
Fabien Potencier 2014-07-25 07:28:54 +02:00
commit 045cbc53cc
2 changed files with 22 additions and 2 deletions

View File

@ -59,8 +59,7 @@ class ExecutableFinder
if (is_dir($path)) {
$dirs[] = $path;
} else {
$file = str_replace(dirname($path), '', $path);
if ($file == $name && is_executable($path)) {
if (basename($path) == $name && is_executable($path)) {
return $path;
}
}

View File

@ -110,6 +110,27 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$this->assertSamePath(PHP_BINARY, $result);
}
public function testFindProcessInOpenBasedir()
{
if (ini_get('open_basedir')) {
$this->markTestSkipped('Cannot test when open_basedir is set');
}
if (!defined('PHP_BINARY')) {
$this->markTestSkipped('Requires the PHP_BINARY constant');
}
$execPath = __DIR__.'/SignalListener.php';
$this->setPath('');
ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
$finder = new ExecutableFinder();
$result = $finder->find($this->getPhpBinaryName(), false);
$this->assertSamePath(PHP_BINARY, $result);
}
private function assertSamePath($expected, $tested)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {