Merge branch 'MDL-54948-master' of git://github.com/lameze/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 21 Jun 2016 09:48:10 +0000 (11:48 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 21 Jun 2016 09:48:10 +0000 (11:48 +0200)
lib/filestorage/file_storage.php
lib/upgradelib.php

index 7bcb8e3..bc4ce79 100644 (file)
@@ -241,14 +241,20 @@ class file_storage {
         $unoconvbin = \escapeshellarg($CFG->pathtounoconv);
         $command = "$unoconvbin --version";
         exec($command, $output);
-        preg_match('/([0-9]+\.[0-9]+)/', $output[0], $matches);
-        $currentversion = (float)$matches[0];
-        $supportedversion = 0.7;
-        if ($currentversion < $supportedversion) {
-            return false;
-        }
+        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) {
+                return false;
+            }
 
-        return true;
+            return true;
+        }
     }
 
     /**
index 252f15a..07afc92 100644 (file)
@@ -2297,13 +2297,19 @@ function check_unoconv_version(environment_results $result) {
         $unoconvbin = \escapeshellarg($CFG->pathtounoconv);
         $command = "$unoconvbin --version";
         exec($command, $output);
-        preg_match('/([0-9]+\.[0-9]+)/', $output[0], $matches);
-        $currentversion = (float)$matches[0];
-        $supportedversion = 0.7;
-        if ($currentversion < $supportedversion) {
-            $result->setInfo('unoconv version not supported');
-            $result->setStatus(false);
-            return $result;
+        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;
+            }
         }
     }
     return null;