MDL-54948 core_upgrade: fix check_unoconv_version logic
authorSimey Lameze <simey@moodle.com>
Wed, 22 Jun 2016 05:36:02 +0000 (13:36 +0800)
committerSimey Lameze <simey@moodle.com>
Wed, 22 Jun 2016 05:44:48 +0000 (13:44 +0800)
lib/upgradelib.php

index 07afc92..f8c95cd 100644 (file)
@@ -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;