Skip to content

Commit be7c3e3

Browse files
authored
Merge pull request #23715 from nextcloud/backport/23645/stable18
[stable18] Check if array elements exist before using them
2 parents 88642c6 + ac180a1 commit be7c3e3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ private function doesDirectoryExist($path) {
163163
'MaxKeys' => 1,
164164
'Delimiter' => '/',
165165
]);
166-
$this->directoryCache[$path] = ($result['Contents'][0]['Key'] === rtrim($path, '/') . '/') || $result['CommonPrefixes'];
166+
167+
if ((isset($result['Contents'][0]['Key']) && $result['Contents'][0]['Key'] === rtrim($path, '/') . '/')
168+
|| isset($result['CommonPrefixes'])) {
169+
$this->directoryCache[$path] = true;
170+
} else {
171+
$this->directoryCache[$path] = false;
172+
}
167173
} catch (S3Exception $e) {
168174
if ($e->getStatusCode() === 403) {
169175
$this->directoryCache[$path] = false;

0 commit comments

Comments
 (0)