From 84440fe3d26e7126ebba704e4bd201ff05e49dd3 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 22 Jun 2016 13:36:02 +0800 Subject: [PATCH] MDL-54948 core_upgrade: fix check_unoconv_version logic --- lib/upgradelib.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 07afc92b0c3..f8c95cd64fb 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2294,22 +2294,25 @@ function check_unoconv_version(environment_results $result) { global $CFG; if (!during_initial_install() && !empty($CFG->pathtounoconv) && file_is_executable(trim($CFG->pathtounoconv))) { + $currentversion = 0; + $supportedversion = 0.7; $unoconvbin = \escapeshellarg($CFG->pathtounoconv); $command = "$unoconvbin --version"; exec($command, $output); + + // If the command execution returned some output, then get the unoconv version. if ($output) { - $currentversion = 0; foreach ($output as $response) { if (preg_match('/unoconv (\\d+\\.\\d+)/', $response, $matches)) { $currentversion = (float)$matches[1]; } } - $supportedversion = 0.7; - if ($currentversion < $supportedversion) { - $result->setInfo('unoconv version not supported'); - $result->setStatus(false); - return $result; - } + } + + if ($currentversion < $supportedversion) { + $result->setInfo('unoconv version not supported'); + $result->setStatus(false); + return $result; } } return null;