Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40c08c6

Browse filesBrowse files
committed
[Process] Handle idle timeout and disable output conflict
1 parent b7c158a commit 40c08c6
Copy full SHA for 40c08c6

File tree

Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ public function disableOutput()
418418
if ($this->isRunning()) {
419419
throw new RuntimeException('Disabling output while the process is running is not possible.');
420420
}
421+
if (null !== $this->idleTimeout) {
422+
throw new LogicException('Output can not be disabled while an idle timeout is set.');
423+
}
421424

422425
$this->outputDisabled = true;
423426

@@ -870,6 +873,10 @@ public function setTimeout($timeout)
870873
*/
871874
public function setIdleTimeout($timeout)
872875
{
876+
if (null !== $timeout && $this->outputDisabled) {
877+
throw new LogicException('Idle timeout can not be set while the output is disabled.');
878+
}
879+
873880
$this->idleTimeout = $this->validateTimeout($timeout);
874881

875882
return $this;

‎src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/AbstractProcessTest.php
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,29 @@ public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
737737
$p->disableOutput();
738738
}
739739

740+
public function testDisableOutputWhileIdleTimeoutIsSet()
741+
{
742+
$process = $this->getProcess('sleep 3');
743+
$process->setIdleTimeout(1);
744+
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Output can not be disabled while an idle timeout is set.');
745+
$process->disableOutput();
746+
}
747+
748+
public function testSetIdleTimeoutWhileOutputIsDisabled()
749+
{
750+
$process = $this->getProcess('sleep 3');
751+
$process->disableOutput();
752+
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Idle timeout can not be set while the output is disabled.');
753+
$process->setIdleTimeout(1);
754+
}
755+
756+
public function testSetNullIdleTimeoutWhileOutputIsDisabled()
757+
{
758+
$process = $this->getProcess('sleep 3');
759+
$process->disableOutput();
760+
$process->setIdleTimeout(null);
761+
}
762+
740763
/**
741764
* @dataProvider provideStartMethods
742765
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.