From ce796cf0cf011084320b7bea0c724dd212351f6e Mon Sep 17 00:00:00 2001 From: Mikael Lindqvist Date: Mon, 26 Sep 2016 12:05:02 +0200 Subject: [PATCH] don't fail silently in createExportFile --- h5p-default-storage.class.php | 11 +++++++++-- h5p.classes.php | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index a1cd27f..4d0385f 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -132,11 +132,18 @@ class H5PDefaultStorage implements \H5PFileStorage { * Path on file system to temporary export file. * @param string $filename * Name of export file. + * @throws Exception Unable to save the file */ public function saveExport($source, $filename) { $this->deleteExport($filename); - self::dirReady("{$this->path}/exports"); - copy($source, "{$this->path}/exports/{$filename}"); + + if (!self::dirReady("{$this->path}/exports")) { + throw new Exception("Unable to create directory for H5P export file."); + } + + if (!copy($source, "{$this->path}/exports/{$filename}")) { + throw new Exception("Unable to save H5P export file."); + } } /** diff --git a/h5p.classes.php b/h5p.classes.php index c1892cd..4d903af 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1595,6 +1595,7 @@ Class H5PExport { } catch (Exception $e) { $this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage())); + return false; } unlink($tmpFile);