Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit acdafc7

Browse files
Merge branch '6.4' into 7.0
* 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 ...
2 parents 6075f9a + 9973636 commit acdafc7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Process.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function start(callable $callback = null, array $env = []): void
299299
$this->resetProcessData();
300300
$this->starttime = $this->lastOutputTime = microtime(true);
301301
$this->callback = $this->buildCallback($callback);
302-
$descriptors = $this->getDescriptors();
302+
$descriptors = $this->getDescriptors(null !== $callback);
303303

304304
if ($this->env) {
305305
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
@@ -1231,15 +1231,15 @@ public static function isPtySupported(): bool
12311231
/**
12321232
* Creates the descriptors needed by the proc_open.
12331233
*/
1234-
private function getDescriptors(): array
1234+
private function getDescriptors(bool $hasCallback): array
12351235
{
12361236
if ($this->input instanceof \Iterator) {
12371237
$this->input->rewind();
12381238
}
12391239
if ('\\' === \DIRECTORY_SEPARATOR) {
1240-
$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->callback);
1240+
$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $hasCallback);
12411241
} else {
1242-
$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->callback);
1242+
$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $hasCallback);
12431243
}
12441244

12451245
return $this->processPipes->getDescriptors();

Tests/ProcessTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ public function testCallbacksAreExecutedWithStart()
200200
$this->assertSame('foo'.\PHP_EOL, $data);
201201
}
202202

203+
public function testReadSupportIsDisabledWithoutCallback()
204+
{
205+
$this->expectException(LogicException::class);
206+
$this->expectExceptionMessage('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');
207+
208+
$process = $this->getProcess('echo foo');
209+
// disabling output + not passing a callback to start() => read support disabled
210+
$process->disableOutput();
211+
$process->start();
212+
$process->wait(function ($type, $buffer) use (&$data) {
213+
$data .= $buffer;
214+
});
215+
}
216+
203217
/**
204218
* tests results from sub processes.
205219
*

0 commit comments

Comments
 (0)