Avoid formatting output from external processes, fixes #8524
parent
7d4d4622ab
commit
d3f1c664d4
|
@ -65,6 +65,22 @@ abstract class BaseIO implements IOInterface, LoggerInterface
|
||||||
$this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
|
$this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
||||||
|
{
|
||||||
|
$this->write($messages, $newline, $verbosity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
||||||
|
{
|
||||||
|
$this->writeError($messages, $newline, $verbosity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for overwrite and set the authentication information for the repository.
|
* Check for overwrite and set the authentication information for the repository.
|
||||||
*
|
*
|
||||||
|
|
|
@ -129,13 +129,29 @@ class ConsoleIO extends BaseIO
|
||||||
$this->doWrite($messages, $newline, true, $verbosity);
|
$this->doWrite($messages, $newline, true, $verbosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
||||||
|
{
|
||||||
|
$this->doWrite($messages, $newline, false, $verbosity, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
|
||||||
|
{
|
||||||
|
$this->doWrite($messages, $newline, true, $verbosity, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $messages
|
* @param array|string $messages
|
||||||
* @param bool $newline
|
* @param bool $newline
|
||||||
* @param bool $stderr
|
* @param bool $stderr
|
||||||
* @param int $verbosity
|
* @param int $verbosity
|
||||||
*/
|
*/
|
||||||
private function doWrite($messages, $newline, $stderr, $verbosity)
|
private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
|
||||||
{
|
{
|
||||||
$sfVerbosity = $this->verbosityMap[$verbosity];
|
$sfVerbosity = $this->verbosityMap[$verbosity];
|
||||||
if ($sfVerbosity > $this->output->getVerbosity()) {
|
if ($sfVerbosity > $this->output->getVerbosity()) {
|
||||||
|
@ -149,6 +165,14 @@ class ConsoleIO extends BaseIO
|
||||||
$sfVerbosity = OutputInterface::OUTPUT_NORMAL;
|
$sfVerbosity = OutputInterface::OUTPUT_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($raw) {
|
||||||
|
if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
|
||||||
|
$sfVerbosity = OutputInterface::OUTPUT_RAW;
|
||||||
|
} else {
|
||||||
|
$sfVerbosity |= OutputInterface::OUTPUT_RAW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $this->startTime) {
|
if (null !== $this->startTime) {
|
||||||
$memoryUsage = memory_get_usage() / 1024 / 1024;
|
$memoryUsage = memory_get_usage() / 1024 / 1024;
|
||||||
$timeSpent = microtime(true) - $this->startTime;
|
$timeSpent = microtime(true) - $this->startTime;
|
||||||
|
|
|
@ -112,10 +112,18 @@ class ProcessExecutor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Process::ERR === $type) {
|
if (method_exists($this->io, 'writeRaw')) {
|
||||||
$this->io->writeError($buffer, false);
|
if (Process::ERR === $type) {
|
||||||
|
$this->io->writeErrorRaw($buffer, false);
|
||||||
|
} else {
|
||||||
|
$this->io->writeRaw($buffer, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->io->write($buffer, false);
|
if (Process::ERR === $type) {
|
||||||
|
$this->io->writeError($buffer, false);
|
||||||
|
} else {
|
||||||
|
$this->io->write($buffer, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,6 @@ class ProcessExecutorTest extends TestCase
|
||||||
$process = new ProcessExecutor(new ConsoleIO(new ArrayInput([]), $output, new HelperSet([])));
|
$process = new ProcessExecutor(new ConsoleIO(new ArrayInput([]), $output, new HelperSet([])));
|
||||||
|
|
||||||
$process->execute('echo \'<error>foo</error>\'');
|
$process->execute('echo \'<error>foo</error>\'');
|
||||||
$this->assertSame('<error>foo</error>', $output->fetch());
|
$this->assertSame('<error>foo</error>'.PHP_EOL, $output->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue