From: mjollnir_ Date: Fri, 5 Sep 2008 12:42:27 +0000 (+0000) Subject: MDL-15777 - better handling of integration with file api in portfolio mahara plugin X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=432ad8bf3beeafedd0039ad9969dc09e30007bcd;p=moodle.git MDL-15777 - better handling of integration with file api in portfolio mahara plugin --- diff --git a/portfolio/type/mahara/lib.php b/portfolio/type/mahara/lib.php index 93f58145cc..7fb366413b 100644 --- a/portfolio/type/mahara/lib.php +++ b/portfolio/type/mahara/lib.php @@ -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'));