MDL-15777 - better handling of integration with file api in portfolio mahara plugin
authormjollnir_ <mjollnir_>
Fri, 5 Sep 2008 12:42:27 +0000 (12:42 +0000)
committermjollnir_ <mjollnir_>
Fri, 5 Sep 2008 12:42:27 +0000 (12:42 +0000)
portfolio/type/mahara/lib.php

index 93f5814..7fb3664 100644 (file)
@@ -304,10 +304,14 @@ class portfolio_plugin_mahara extends portfolio_plugin_pull_base {
         try {
             $i = $exporter->get('instance');
             $f = $i->get('file');
-            if (empty($f)) {
+            if (empty($f) || !($f instanceof stored_file)) {
                 exit(mnet_server_fault(8012, 'could not find file in transfer object - weird error'));
             }
-            $c = $f->get_content();
+            try {
+                $c = $f->get_content();
+            } catch (file_exception $e) {
+                exit(mnet_server_fault(8013, 'found file object but couldn\'t get contents - weird error: ' . $e->getMessage()));
+            }
             $contents = base64_encode($c);
         } catch (Exception $e) {
             exit(mnet_server_fault(8013, 'could not get file to send'));