Skip to content

Commit fa5f6e1

Browse files
authored
Merge pull request phpredis#1365 from remicollet/issue-runcmd
use PHP_BINARY instead of php and allow override
2 parents a3cc1f0 + c4e4248 commit fa5f6e1

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/RedisTest.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5560,9 +5560,8 @@ private function startSessionProcess($sessionId, $sleepTime, $background, $maxEx
55605560
}
55615561
$commandParameters = array_map('escapeshellarg', $commandParameters);
55625562

5563-
$command = 'php ' . __DIR__ . '/startSession.php ' . implode(' ', $commandParameters);
5563+
$command = self::getPhpCommand('startSession.php') . implode(' ', $commandParameters);
55645564
$command .= $background ? ' 2>/dev/null > /dev/null &' : ' 2>&1';
5565-
55665565
exec($command, $output);
55675566
return ($background || (count($output) == 1 && $output[0] == 'SUCCESS')) ? true : false;
55685567
}
@@ -5576,7 +5575,7 @@ private function startSessionProcess($sessionId, $sleepTime, $background, $maxEx
55765575
*/
55775576
private function getSessionData($sessionId, $sessionLifetime = 1440)
55785577
{
5579-
$command = 'php ' . __DIR__ . '/getSessionData.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . escapeshellarg($sessionId) . ' ' . escapeshellarg($sessionLifetime);
5578+
$command = self::getPhpCommand('getSessionData.php') . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . escapeshellarg($sessionId) . ' ' . escapeshellarg($sessionLifetime);
55805579
exec($command, $output);
55815580

55825581
return $output[0];
@@ -5594,11 +5593,31 @@ private function regenerateSessionId($sessionId, $locking = false, $destroyPrevi
55945593
{
55955594
$args = array_map('escapeshellarg', array($sessionId, $locking, $destroyPrevious, $sessionProxy));
55965595

5597-
$command = 'php --no-php-ini --define extension=igbinary.so --define extension=' . __DIR__ . '/../modules/redis.so ' . __DIR__ . '/regenerateSessionId.php ' . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . implode(' ', $args);
5596+
$command = self::getPhpCommand('regenerateSessionId.php') . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . implode(' ', $args);
55985597

55995598
exec($command, $output);
56005599

56015600
return $output[0];
56025601
}
5602+
5603+
/**
5604+
* Return command to launch PHP with built extension enabled
5605+
* taking care of environment (TEST_PHP_EXECUTABLE and TEST_PHP_ARGS)
5606+
*
5607+
* @param string $script
5608+
*
5609+
* @return string
5610+
*/
5611+
private function getPhpCommand($script)
5612+
{
5613+
static $cmd = NULL;
5614+
5615+
if (!$cmd) {
5616+
$cmd = (getenv('TEST_PHP_EXECUTABLE') ?: (defined('PHP_BINARY') ? PHP_BINARY : 'php')); // PHP_BINARY is 5.4+
5617+
$cmd .= ' ';
5618+
$cmd .= (getenv('TEST_PHP_ARGS') ?: '--no-php-ini --define extension=igbinary.so --define extension=' . dirname(__DIR__) . '/modules/redis.so');
5619+
}
5620+
return $cmd . ' ' . __DIR__ . '/' . $script . ' ';
5621+
}
56035622
}
56045623
?>

0 commit comments

Comments
 (0)