8000 bug #17424 [2.7][Process] Update in 2.7 for stream-based output stora… · symfony/symfony@a4f7fbf · GitHub
[go: up one dir, main page]

Skip to content

Commit a4f7fbf

Browse files
committed
bug #17424 [2.7][Process] Update in 2.7 for stream-based output storage (romainneutron)
This PR was merged into the 2.7 branch. Discussion ---------- [2.7][Process] Update in 2.7 for stream-based output storage | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17390 | License | MIT This PR should be rebased once #17423 has been merged. It contains fixes related to methode `Process::getErrorOutput` and `Process::getOutput` that do not exist in branch 2.3 Commits ------- 2d931f4 [Process] Use stream based storage to avoid memory issues
2 parents 6ec5537 + 2d931f4 commit a4f7fbf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ public function getOutput()
491491
*/
492492
public function getIncrementalOutput()
493493
{
494+
if ($this->outputDisabled) {
495+
throw new LogicException('Output has been disabled.');
496+
}
497+
494498
$this->requireProcessIsStarted(__FUNCTION__);
495499

496500
$latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
@@ -510,7 +514,8 @@ public function getIncrementalOutput()
510514
*/
511515
public function clearOutput()
512516
{
513-
$this->stdout = '';
517+
ftruncate($this->stdout, 0);
518+
fseek($this->stdout, 0);
514519
$this->incrementalOutputOffset = 0;
515520

516521
return $this;
@@ -555,6 +560,10 @@ public function getErrorOutput()
555560
*/
556561
public function getIncrementalErrorOutput()
557562
{
563+
if ($this->outputDisabled) {
564+
throw new LogicException('Output has been disabled.');
565+
}
566+
558567
$this->requireProcessIsStarted(__FUNCTION__);
559568

560569
$latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
@@ -574,7 +583,8 @@ public function getIncrementalErrorOutput()
574583
*/
575584
public function clearErrorOutput()
576585
{
577-
$this->stderr = '';
586+
ftruncate($this->stderr, 0);
587+
fseek($this->stderr, 0);
578588
$this->incrementalErrorOutputOffset = 0;
579589

580590
return $this;

0 commit comments

Comments
 (0)
0