]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure to not pass null to DateTime::createFromFormat 35162/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 14 Nov 2022 15:23:50 +0000 (16:23 +0100)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Mon, 14 Nov 2022 18:43:15 +0000 (18:43 +0000)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/dav/lib/Files/FileSearchBackend.php
apps/files_external/lib/Lib/Storage/FTP.php
apps/sharebymail/lib/ShareByMailProvider.php
apps/workflowengine/lib/Check/RequestTime.php

index 7ee827798493d237d95121737d968c852d0552ea..3a4f90a4bae1fd5c999f084ac3332edfdd29cf90 100644 (file)
@@ -405,7 +405,7 @@ class FileSearchBackend implements ISearchBackend {
                                if (is_numeric($value)) {
                                        return max(0, 0 + $value);
                                }
-                               $date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, $value);
+                               $date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, (string)$value);
                                return ($date instanceof \DateTime && $date->getTimestamp() !== false) ? $date->getTimestamp() : 0;
                        default:
                                return $value;
index d424ffe3cdd3263e053ffc198c34e6fa00a6d2cc..998d147b7c7168239670bf7adc2e2c25da179ca4 100644 (file)
@@ -123,7 +123,7 @@ class FTP extends Common {
                                        return $item['type'] === 'cdir';
                                }));
                                if ($currentDir) {
-                                       $time = \DateTime::createFromFormat('YmdHis', $currentDir['modify']);
+                                       $time = \DateTime::createFromFormat('YmdHis', $currentDir['modify'] ?? '');
                                        if ($time === false) {
                                                throw new \Exception("Invalid date format for directory: $currentDir");
                                        }
@@ -269,7 +269,7 @@ class FTP extends Common {
                        case 'wb':
                        case 'wb+':
                                $useExisting = false;
-                       // no break
+                               // no break
                        case 'a':
                        case 'ab':
                        case 'r+':
index ee14e354c5284850ef2b756a83e42b3985f8e657..b614c894896742b292ca9a0c2a12d595ebb410fc 100644 (file)
@@ -1043,8 +1043,8 @@ class ShareByMailProvider implements IShareProvider {
                $share->setShareTime($shareTime);
                $share->setSharedWith($data['share_with']);
                $share->setPassword($data['password']);
-               $passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time']);
-               $share->setPasswordExpirationTime($passwordExpirationTime !== false? $passwordExpirationTime : null);
+               $passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
+               $share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
                $share->setLabel($data['label']);
                $share->setSendPasswordByTalk((bool)$data['password_by_talk']);
                $share->setHideDownload((bool)$data['hide_download']);
@@ -1141,7 +1141,6 @@ class ShareByMailProvider implements IShareProvider {
         * @throws ShareNotFound
         */
        protected function getRawShare($id) {
-
                // Now fetch the inserted share and create a complete share object
                $qb = $this->dbConnection->getQueryBuilder();
                $qb->select('*')
index b7a2f725451687be2bf45dd763ec06204e192848..be28f8ead1597ed5bb22c2b31756e2c1328a6a5d 100644 (file)
@@ -109,12 +109,12 @@ class RequestTime implements ICheck {
                }
 
                $values = json_decode($value, true);
-               $time1 = \DateTime::createFromFormat('H:i e', $values[0]);
+               $time1 = \DateTime::createFromFormat('H:i e', (string)$values[0]);
                if ($time1 === false) {
                        throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
                }
 
-               $time2 = \DateTime::createFromFormat('H:i e', $values[1]);
+               $time2 = \DateTime::createFromFormat('H:i e', (string)$values[1]);
                if ($time2 === false) {
                        throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
                }