diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-05-08 11:32:52 +0200 |
---|---|---|
committer | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-05-12 18:38:44 +0200 |
commit | e0913119240432a5e6983943ab9e5c6cae32f2c7 (patch) | |
tree | 8dd41b7d0a6cc9f680aa1e3838a2a679721dc153 | |
parent | bb720fc6faa5c59674196c2366a5098b007d00dd (diff) | |
download | nextcloud-server-backport/52686/stable30.tar.gz nextcloud-server-backport/52686/stable30.zip |
fix(files_external): Safely check if the timestamp is numericbackport/52686/stable30
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r-- | apps/files_external/lib/Lib/Storage/Swift.php | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 6fb1c16b96f..9a591f5ae09 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -290,9 +290,8 @@ class Swift extends \OC\Files\Storage\Common { } } - public function stat($path) { + public function stat(string $path): array|false { $path = $this->normalizePath($path); - if ($path === '.') { $path = ''; } elseif ($this->is_dir($path)) { @@ -312,22 +311,23 @@ class Swift extends \OC\Files\Storage\Common { return false; } - $dateTime = $object->lastModified ? \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified) : false; - $mtime = $dateTime ? $dateTime->getTimestamp() : null; - $objectMetadata = $object->getMetadata(); - if (isset($objectMetadata['timestamp'])) { - $mtime = $objectMetadata['timestamp']; + $mtime = null; + if (!empty($object->lastModified)) { + $dateTime = \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified); + if ($dateTime !== false) { + $mtime = $dateTime->getTimestamp(); + } } - if (!empty($mtime)) { - $mtime = floor($mtime); + if (is_numeric($object->getMetadata()['timestamp'] ?? null)) { + $mtime = (float)$object->getMetadata()['timestamp']; } - $stat = []; - $stat['size'] = (int) $object->contentLength; - $stat['mtime'] = $mtime; - $stat['atime'] = time(); - return $stat; + return [ + 'size' => (int)$object->contentLength, + 'mtime' => isset($mtime) ? (int)floor($mtime) : null, + 'atime' => time(), + ]; } public function filetype($path) { |