MDL-54948 core_files: make the check consistent on unoconv test page
authorSimey Lameze <simey@moodle.com>
Tue, 21 Jun 2016 01:36:44 +0000 (09:36 +0800)
committerSimey Lameze <simey@moodle.com>
Tue, 21 Jun 2016 01:36:44 +0000 (09:36 +0800)
lib/filestorage/file_storage.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;
+        }
     }
 
     /**