Skip to content

Commit f183063

Browse files
committed
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 <[email protected]>
1 parent bc6a3e8 commit f183063

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,10 @@ public function createShare(
661661
// Handle mail send
662662
if (is_null($sendMail)) {
663663
// Define a default behavior when sendMail is not provided
664-
if ($shareType === IShare::TYPE_EMAIL && strlen($shareWith) !== 0) {
665-
// For email shares, the default is to send the mail
666-
$share->setMailSend(true);
667-
} else {
668-
// For all other share types, the default is to not send the mail
669-
$share->setMailSend(false);
670-
}
664+
// For email shares with a valid recipient, the default is to send the mail
665+
// For all other share types, the default is to not send the mail
666+
$allowSendMail = ($shareType === IShare::TYPE_EMAIL && !empty($shareWith));
667+
$share->setMailSend($allowSendMail);
671668
} else {
672669
$share->setMailSend($sendMail === 'true');
673670
}

0 commit comments

Comments
 (0)