Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4: (33 commits)
  [Console][FrameworkBundle][HttpKernel][WebProfilerBundle] Enable profiling commands
  [AssetMapper] Disable profiler when the "dev server" respond
  Adds translations for Portuguese (pt)
  [AssetMapper] Link needs as="style"
  Allow Symfony 7.0 on Phrase translation provider
  [Mime] Throw InvalidArgumentException on invalid form field type inside array
  [Mailer][Bridges] Allow Symfony 7
  [Tests] Use `JsonMockResponse` where applicable
  [FrameworkBundle][HttpKernel] Introduce `$buildDir` argument to `WarmableInterface::warmup` to warm read-only artefacts in `build_dir`
  [ErrorHandler] Fix expected missing return types
  [Form] Fix merging params & files when "multiple" is enabled
  [HttpFoundation] Do not swallow trailing `=` in cookie value
  Fix markdown in README files
  Handle Sendinblue error responses without a message key
  Handle Brevo error responses without a message key
  [Scheduler] Add failureEvent
  [Notifier][Bridges] Allow Symfony 7
  [Mailer][Brevo][Sendinblue] Fix typo
  [Serializer] Fix collecting only first missing constructor argument
  [ErrorHandler] Fix file link format call in trace view
  ...
  • Loading branch information
nicolas-grekas committed Oct 17, 2023
2 parents 6075f9a + 9973636 commit acdafc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function start(callable $callback = null, array $env = []): void
$this->resetProcessData();
$this->starttime = $this->lastOutputTime = microtime(true);
$this->callback = $this->buildCallback($callback);
$descriptors = $this->getDescriptors();
$descriptors = $this->getDescriptors(null !== $callback);

if ($this->env) {
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
Expand Down Expand Up @@ -1231,15 +1231,15 @@ public static function isPtySupported(): bool
/**
* Creates the descriptors needed by the proc_open.
*/
private function getDescriptors(): array
private function getDescriptors(bool $hasCallback): array
{
if ($this->input instanceof \Iterator) {
$this->input->rewind();
}
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->callback);
$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $hasCallback);
} else {
$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->callback);
$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $hasCallback);
}

return $this->processPipes->getDescriptors();
Expand Down
14 changes: 14 additions & 0 deletions Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ public function testCallbacksAreExecutedWithStart()
$this->assertSame('foo'.\PHP_EOL, $data);
}

public function testReadSupportIsDisabledWithoutCallback()
{
$this->expectException(LogicException::class);
$this->expectExceptionMessage('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');

$process = $this->getProcess('echo foo');
// disabling output + not passing a callback to start() => read support disabled
$process->disableOutput();
$process->start();
$process->wait(function ($type, $buffer) use (&$data) {
$data .= $buffer;
});
}

/**
* tests results from sub processes.
*
Expand Down

0 comments on commit acdafc7

Please sign in to comment.