From b49e576180bc55a565b3d2784b878130fdc28d59 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:40:44 +0100 Subject: [PATCH] fix: ensure DateTime conversion to string Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- .../lib/Controller/ShareAPIController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 5b69d522545f1..e4f93b8e2bd7b 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -780,6 +780,9 @@ public function createShare( $share->setSharedWith($shareWith); $share->setPermissions($permissions); if ($expireDate !== '') { + if ($expireDate instanceof \DateTime) { + $expireDate = $expireDate->format('Y-m-d'); + } try { $expireDate = $this->parseDate($expireDate); $share->setExpirationDate($expireDate); @@ -801,6 +804,9 @@ public function createShare( $share->setSharedWith($shareWith); $share->setPermissions($permissions); if ($expireDate !== '') { + if ($expireDate instanceof \DateTime) { + $expireDate = $expireDate->format('Y-m-d'); + } try { $expireDate = $this->parseDate($expireDate); $share->setExpirationDate($expireDate); @@ -845,6 +851,9 @@ public function createShare( //Expire date if ($expireDate !== '') { + if ($expireDate instanceof \DateTime) { + $expireDate = $expireDate->format('Y-m-d'); + } try { $expireDate = $this->parseDate($expireDate); $share->setExpirationDate($expireDate); @@ -1384,6 +1393,9 @@ public function updateShare( if ($expireDate === '') { $share->setExpirationDate(null); } elseif ($expireDate !== null) { + if ($expireDate instanceof \DateTime) { + $expireDate = $expireDate->format('Y-m-d'); + } try { $expireDate = $this->parseDate($expireDate); } catch (\Exception $e) {