Skip to content

Commit 017b0f5

Browse files
authored
Merge pull request #35162 from nextcloud/backport/35157/stable24
[stable24] Make sure to not pass null to DateTime::createFromFormat
2 parents 942c439 + eb8b008 commit 017b0f5

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ private function castValue(SearchPropertyDefinition $property, $value) {
405405
if (is_numeric($value)) {
406406
return max(0, 0 + $value);
407407
}
408-
$date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, $value);
408+
$date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, (string)$value);
409409
return ($date instanceof \DateTime && $date->getTimestamp() !== false) ? $date->getTimestamp() : 0;
410410
default:
411411
return $value;

apps/files_external/lib/Lib/Storage/FTP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function filemtime($path) {
123123
return $item['type'] === 'cdir';
124124
}));
125125
if ($currentDir) {
126-
$time = \DateTime::createFromFormat('YmdHis', $currentDir['modify']);
126+
$time = \DateTime::createFromFormat('YmdHis', $currentDir['modify'] ?? '');
127127
if ($time === false) {
128128
throw new \Exception("Invalid date format for directory: $currentDir");
129129
}
@@ -269,7 +269,7 @@ public function fopen($path, $mode) {
269269
case 'wb':
270270
case 'wb+':
271271
$useExisting = false;
272-
// no break
272+
// no break
273273
case 'a':
274274
case 'ab':
275275
case 'r+':

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ protected function createShareObject($data) {
10431043
$share->setShareTime($shareTime);
10441044
$share->setSharedWith($data['share_with']);
10451045
$share->setPassword($data['password']);
1046-
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time']);
1047-
$share->setPasswordExpirationTime($passwordExpirationTime !== false? $passwordExpirationTime : null);
1046+
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
1047+
$share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
10481048
$share->setLabel($data['label']);
10491049
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
10501050
$share->setHideDownload((bool)$data['hide_download']);
@@ -1141,7 +1141,6 @@ public function userDeletedFromGroup($uid, $gid) {
11411141
* @throws ShareNotFound
11421142
*/
11431143
protected function getRawShare($id) {
1144-
11451144
// Now fetch the inserted share and create a complete share object
11461145
$qb = $this->dbConnection->getQueryBuilder();
11471146
$qb->select('*')

apps/workflowengine/lib/Check/RequestTime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ public function validateCheck($operator, $value) {
109109
}
110110

111111
$values = json_decode($value, true);
112-
$time1 = \DateTime::createFromFormat('H:i e', $values[0]);
112+
$time1 = \DateTime::createFromFormat('H:i e', (string)$values[0]);
113113
if ($time1 === false) {
114114
throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
115115
}
116116

117-
$time2 = \DateTime::createFromFormat('H:i e', $values[1]);
117+
$time2 = \DateTime::createFromFormat('H:i e', (string)$values[1]);
118118
if ($time2 === false) {
119119
throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
120120
}

0 commit comments

Comments
 (0)