Merge pull request #35163 from nextcloud/backport/35157/stable23

[stable23] Make sure to not pass null to DateTime::createFromFormat
This commit is contained in:
Côme Chilliet 2022-11-22 10:10:56 +01:00 committed by GitHub
commit 274cbc484e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 6 deletions

View file

@ -376,7 +376,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;

View 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+':

View file

@ -1099,7 +1099,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('*')

View 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);
}