From 64d90d4523e877e13f6e1ad2d1cdd97a70edae27 Mon Sep 17 00:00:00 2001 From: Eric Funk Date: Mon, 1 Jan 2018 12:17:19 +0100 Subject: [PATCH] make JpegOptimPostProcessor Symfony4 compatible use Process instead of ProcessBuilder https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md The Symfony\Component\Process\ProcessBuilder class has been removed, use the Symfony\Component\Process\Process class directly instead. I removed ProcessBuilder and use Process instead - this should have no sideeffects on existing 3.x installations - Process is also supported in those cases --- .../PostProcessor/JpegOptimPostProcessor.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php b/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php index a5190900a..a5d251224 100644 --- a/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php +++ b/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php @@ -15,7 +15,7 @@ use Liip\ImagineBundle\Binary\FileBinaryInterface; use Liip\ImagineBundle\Model\Binary; use Symfony\Component\Process\Exception\ProcessFailedException; -use Symfony\Component\Process\ProcessBuilder; +use Symfony\Component\Process\Process; class JpegOptimPostProcessor implements PostProcessorInterface, ConfigurablePostProcessorInterface { @@ -141,33 +141,32 @@ public function processWithConfiguration(BinaryInterface $binary, array $options throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', $tempDir)); } - $pb = new ProcessBuilder([$this->jpegoptimBin]); - + $commandline = $this->jpegoptimBin; $stripAll = array_key_exists('strip_all', $options) ? $options['strip_all'] : $this->stripAll; if ($stripAll) { - $pb->add('--strip-all'); + $commandline .= ' --strip-all'; } $max = array_key_exists('max', $options) ? $options['max'] : $this->max; if ($max) { - $pb->add('--max='.$max); + $commandline .= ' --max='.$max; } $progressive = array_key_exists('progressive', $options) ? $options['progressive'] : $this->progressive; if ($progressive) { - $pb->add('--all-progressive'); + $commandline .= ' --all-progressive'; } else { - $pb->add('--all-normal'); + $commandline .= ' --all-normal'; } - $pb->add($input); + $commandline .= ' '.$input; if ($binary instanceof FileBinaryInterface) { copy($binary->getPath(), $input); } else { file_put_contents($input, $binary->getContent()); } - $proc = $pb->getProcess(); + $proc = new Process($commandline); $proc->run(); if (false !== strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {