From 227b8462d8ece172598611c2167d1f31cd15b401 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Thu, 24 Oct 2024 17:47:07 +0100 Subject: [PATCH] refactor(ShareApiController): Check for null and empty strings with empty() Proactive measure to avoid warnings in higher php versions as well possible type errors Signed-off-by: fenn-cs --- .../lib/Controller/ShareAPIController.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index ebe40b7edd9b3..d6800acf6555f 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -661,13 +661,10 @@ public function createShare( // Handle mail send if (is_null($sendMail)) { // Define a default behavior when sendMail is not provided - if ($shareType === IShare::TYPE_EMAIL && strlen($shareWith) !== 0) { - // For email shares, the default is to send the mail - $share->setMailSend(true); - } else { - // For all other share types, the default is to not send the mail - $share->setMailSend(false); - } + // For email shares with a valid recipient, the default is to send the mail + // For all other share types, the default is to not send the mail + $allowSendMail = ($shareType === IShare::TYPE_EMAIL && $shareWith !== null && $shareWith !== ''); + $share->setMailSend($allowSendMail); } else { $share->setMailSend($sendMail === 'true'); }