1
0
Fork 0

Forward composer memory_limit to child processes, fixes #6075

pull/6099/head
Jordi Boggiano 2017-01-22 19:03:22 +01:00
parent 9a26a9e8f8
commit 7aa7c3ced3
1 changed files with 15 additions and 12 deletions

View File

@ -175,12 +175,7 @@ class EventDispatcher
$args = $event->getArguments(); $args = $event->getArguments();
$flags = $event->getFlags(); $flags = $event->getFlags();
if (substr($callable, 0, 10) === '@composer ') { if (substr($callable, 0, 10) === '@composer ') {
$finder = new PhpExecutableFinder(); $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
$phpPath = $finder->find();
if (!$phpPath) {
throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName);
}
$exec = ProcessExecutor::escape($phpPath) . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
if (0 !== ($exitCode = $this->process->execute($exec))) { if (0 !== ($exitCode = $this->process->execute($exec))) {
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName())); $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));
@ -234,12 +229,7 @@ class EventDispatcher
} }
if (substr($exec, 0, 5) === '@php ') { if (substr($exec, 0, 5) === '@php ') {
$finder = new PhpExecutableFinder(); $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
$phpPath = $finder->find();
if (!$phpPath) {
throw new \RuntimeException('Failed to locate PHP binary to execute "'.$exec.'"');
}
$exec = $phpPath . ' ' . substr($exec, 5);
} }
if (0 !== ($exitCode = $this->process->execute($exec))) { if (0 !== ($exitCode = $this->process->execute($exec))) {
@ -259,6 +249,19 @@ class EventDispatcher
return $return; return $return;
} }
protected function getPhpExecCommand()
{
$finder = new PhpExecutableFinder();
$phpPath = $finder->find();
if (!$phpPath) {
throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName);
}
$memoryFlag = ' -d memory_limit='.ini_get('memory_limit');
return ProcessExecutor::escape($phpPath) . $memoryFlag;
}
/** /**
* @param string $className * @param string $className
* @param string $methodName * @param string $methodName