From d2c7d70f49bd01b08977360998616c252bbfa9ea Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Mon, 14 Sep 2020 20:37:48 +0300 Subject: [PATCH] Fix "Implement a class for automatic temporary file handling" TemporaryFile::commit throws instead of returning a bool. --- lib/media/mediafile.php | 7 ++++++- plugins/FFmpeg/FFmpegPlugin.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/media/mediafile.php b/lib/media/mediafile.php index 65f19e6d02..4dbb924355 100644 --- a/lib/media/mediafile.php +++ b/lib/media/mediafile.php @@ -517,7 +517,12 @@ class MediaFile if ($media === 'image') { $result = rename($outpath, $filepath); } else { - $result = $tempfile->commit($filepath); + try { + $tempfile->commit($filepath); + $result = true; + } catch (TemporaryFileException $e) { + $result = false; + } } if (!$result) { // TRANS: Server exception thrown when a file upload operation fails because the file could diff --git a/plugins/FFmpeg/FFmpegPlugin.php b/plugins/FFmpeg/FFmpegPlugin.php index e042629fa0..c939f10edb 100644 --- a/plugins/FFmpeg/FFmpegPlugin.php +++ b/plugins/FFmpeg/FFmpegPlugin.php @@ -115,7 +115,12 @@ class FFmpegPlugin extends Plugin } if ($success) { - $success = $tempfile->commit($outpath); + try { + $tempfile->commit($outpath); + } catch (TemporaryFileException $e) { + $this->log(LOG_ERR, 'Unable to save the GIF image'); + $success = false; + } } @unlink($palette);