Skip to content

Commit

Permalink
Check for process constructor deprecation in Symfony 4.2 and use from…
Browse files Browse the repository at this point in the history
…ShellCommandline if available
  • Loading branch information
bobvandevijver committed Sep 2, 2020
1 parent a0a2564 commit 0f82276
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Generator/LatexGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 7 additions & 1 deletion Latex/Element/IncludePdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0f82276

Please sign in to comment.