From 0f822765fe7d7bcd1addea42ef19febcf2bf05c0 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Wed, 2 Sep 2020 13:22:43 +0200 Subject: [PATCH] Check for process constructor deprecation in Symfony 4.2 and use fromShellCommandline if available --- Generator/LatexGenerator.php | 10 ++++++++-- Latex/Element/IncludePdf.php | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Generator/LatexGenerator.php b/Generator/LatexGenerator.php index 930871f..71767e6 100644 --- a/Generator/LatexGenerator.php +++ b/Generator/LatexGenerator.php @@ -349,13 +349,19 @@ protected function compilePdf($texLocation, array $compileOptions = array()) { } unset($output); - $process = new Process(sprintf( + $commandLine = sprintf( 'cd %s && HOME="/tmp" %s %s -interaction=nonstopmode -output-directory="%s" "%s"', $this->outputDir, $this->pdfLatexLocation, $optionsString, $this->outputDir, - $texLocation)); + $texLocation); + if (method_exists(Process::class, 'fromShellCommandline')) { + $process = Process::fromShellCommandline($commandLine); + } else { + $process = new Process($commandLine); + } + $process->setTimeout($this->timeout); $process->run(); $output = explode("\n", $process->getOutput()); diff --git a/Latex/Element/IncludePdf.php b/Latex/Element/IncludePdf.php index 7b9ddeb..bb933e1 100644 --- a/Latex/Element/IncludePdf.php +++ b/Latex/Element/IncludePdf.php @@ -56,7 +56,13 @@ public function __construct($fileLocation, $skipFirstWallpaper = true) */ private function getPDFPages($document) { - $process = new Process("pdfinfo $document"); + $commandLine = sprintf('pdfinfo %s', $document); + if (method_exists(Process::class, 'fromShellCommandline')) { + $process = Process::fromShellCommandline($commandLine); + } else { + $process = new Process($commandLine); + } + $process->run(); if($process->getExitCode() !== 0){ return 0;