MDL-54948 core_files: return false if theres no output from unoconv
authorSimey Lameze <simey@moodle.com>
Thu, 23 Jun 2016 00:37:23 +0000 (08:37 +0800)
committerSimey Lameze <simey@moodle.com>
Thu, 23 Jun 2016 00:37:23 +0000 (08:37 +0800)
lib/filestorage/file_storage.php

index bc4ce79..18e3570 100644 (file)
@@ -238,23 +238,24 @@ class file_storage {
      */
     public static function can_convert_documents() {
         global $CFG;
+        $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) {
                 return false;
             }
-
             return true;
         }
+        return false;
     }
 
     /**