Commit a902efd6 authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge "Catch missing file exceptions (bug #749863)"

parents 26c6bf3d f26b576c
......@@ -139,8 +139,8 @@ class HtmlExportFile extends HtmlExportArtefactPlugin {
}
else {
$artefact = artefact_instance_from_id($artefactid);
if (!copy($artefact->get_path(), $filesystemdirectory . PluginExportHtml::sanitise_path($artefact->get('title')))) {
throw new SystemException("Unable to copy artefact $artefactid's file");
if (!$artefact->get_path() || !copy($artefact->get_path(), $filesystemdirectory . PluginExportHtml::sanitise_path($artefact->get('title')))) {
throw new SystemException(get_string('nonexistentfile', 'export', $artefact->get('title')));
}
}
}
......
......@@ -99,7 +99,11 @@ default:
export_iframe_die(get_string('unabletoexportportfoliousingoptions', 'export'));
}
$zipfile = $exporter->export();
try {
$zipfile = $exporter->export();
} catch (SystemException $e) {
export_iframe_die($e->getMessage());
}
// Store the filename in the session, and redirect the iframe to it to trigger
// the download. Here it would be nice to trigger the download for everyone,
......
......@@ -563,11 +563,8 @@ class PluginExportLeap extends PluginExport {
* @return filename string use this to pass to add_enclosure_link
*/
public function add_attachment($filepath, $newname) {
if (!file_exists($filepath)) {
throw new ParamOutOfRangeException("Tried to add non existant file $filepath");
}
if (empty($newname)) {
throw new ParamOutOfRangeException("Tried to add non existant file $filepath");
if (!file_exists($filepath) || empty($newname)) {
throw new ParamOutOfRangeException(get_string('nonexistentfile', 'export', $newname));
}
$newname = substr(str_replace('/', '_', $newname), 0, 245);
$this->attachments[] = (object)array('file' => $filepath, 'name' => $newname);
......
......@@ -48,6 +48,7 @@ $string['generateexport'] = 'Generate export';
$string['noexportpluginsenabled'] = 'No export plugins have been enabled by the administrator, so you are unable to use this feature';
$string['justsomecollections'] = 'Just some of my Collections';
$string['justsomeviews'] = 'Just some of my pages';
$string['nonexistentfile'] = "Tried to add non-existent file: '%s'";
$string['pleasewaitwhileyourexportisbeinggenerated'] = 'Please wait while your export is being generated...';
$string['reverseselection'] = 'Reverse selection';
$string['selectall'] = 'Select all';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment