From 2d931f43e07435c6d3eb3e145749d800e6cb36db Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Jan 2016 17:23:05 +0100 Subject: [PATCH] [Process] Use stream based storage to avoid memory issues --- src/Symfony/Component/Process/Process.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 98fa66a940..32704df3f1 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -491,6 +491,10 @@ class Process */ public function getIncrementalOutput() { + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + $this->requireProcessIsStarted(__FUNCTION__); $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset); @@ -510,7 +514,8 @@ class Process */ public function clearOutput() { - $this->stdout = ''; + ftruncate($this->stdout, 0); + fseek($this->stdout, 0); $this->incrementalOutputOffset = 0; return $this; @@ -555,6 +560,10 @@ class Process */ public function getIncrementalErrorOutput() { + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + $this->requireProcessIsStarted(__FUNCTION__); $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset); @@ -574,7 +583,8 @@ class Process */ public function clearErrorOutput() { - $this->stderr = ''; + ftruncate($this->stderr, 0); + fseek($this->stderr, 0); $this->incrementalErrorOutputOffset = 0; return $this;