From 40c43462a0151b3beed9a0c005a9ecbd566cdbb3 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 28 Aug 2020 16:48:16 +0200 Subject: [PATCH] fix: [internal] loading a missing proposal attachment leads to an exception - should be silently logged and notice error sent --- app/Model/ShadowAttribute.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Model/ShadowAttribute.php b/app/Model/ShadowAttribute.php index b3a743316..59287c982 100644 --- a/app/Model/ShadowAttribute.php +++ b/app/Model/ShadowAttribute.php @@ -394,10 +394,19 @@ class ShadowAttribute extends AppModel return in_array($type, $this->zippedDefinitions) || in_array($type, $this->uploadDefinitions); } - public function base64EncodeAttachment($attribute) + public function base64EncodeAttachment(array $attribute) { - $content = $this->loadAttachmentTool()->getShadowContent($attribute['event_id'], $attribute['id']); - return base64_encode($content); + try { + return base64_encode($this->getAttachment($attribute)); + } catch (NotFoundException $e) { + $this->log($e->getMessage(), LOG_NOTICE); + return ''; + } + } + + public function getAttachment($attribute, $path_suffix='') + { + return $this->loadAttachmentTool()->getShadowContent($attribute['event_id'], $attribute['id'], $path_suffix); } public function saveBase64EncodedAttachment($attribute)