Skip to content

Commit daba112

Browse files
authored
Merge pull request #35161 from nextcloud/backport/35157/stable25
[stable25] Make sure to not pass null to DateTime::createFromFormat
2 parents a5961d1 + 058bf13 commit daba112

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
use SearchDAV\Query\Query;
5656

5757
class FileSearchBackend implements ISearchBackend {
58-
const OPERATOR_LIMIT = 100;
58+
public const OPERATOR_LIMIT = 100;
5959

6060
/** @var CachingTree */
6161
private $tree;
@@ -432,7 +432,7 @@ private function castValue(SearchPropertyDefinition $property, $value) {
432432
if (is_numeric($value)) {
433433
return max(0, 0 + $value);
434434
}
435-
$date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, $value);
435+
$date = \DateTime::createFromFormat(\DateTimeInterface::ATOM, (string)$value);
436436
return ($date instanceof \DateTime && $date->getTimestamp() !== false) ? $date->getTimestamp() : 0;
437437
default:
438438
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
@@ -1042,8 +1042,8 @@ protected function createShareObject($data) {
10421042
$share->setShareTime($shareTime);
10431043
$share->setSharedWith($data['share_with']);
10441044
$share->setPassword($data['password']);
1045-
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time']);
1046-
$share->setPasswordExpirationTime($passwordExpirationTime !== false? $passwordExpirationTime : null);
1045+
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
1046+
$share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
10471047
$share->setLabel($data['label']);
10481048
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
10491049
$share->setHideDownload((bool)$data['hide_download']);
@@ -1140,7 +1140,6 @@ public function userDeletedFromGroup($uid, $gid) {
11401140
* @throws ShareNotFound
11411141
*/
11421142
protected function getRawShare($id) {
1143-
11441143
// Now fetch the inserted share and create a complete share object
11451144
$qb = $this->dbConnection->getQueryBuilder();
11461145
$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)