Skip to content

Commit b71c90b

Browse files
authored
Merge pull request #9650 from nextcloud/backport/8842/stable13
[stable13] fix(AmazonS3): fix loop $result['Contents'] error
2 parents d6ab2a4 + 65bb120 commit b71c90b

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,17 @@ public function opendir($path) {
292292
$files[] = substr(trim($prefix['Prefix'], '/'), strlen($path));
293293
}
294294
}
295-
foreach ($result['Contents'] as $object) {
296-
if (isset($object['Key']) && $object['Key'] === $path) {
297-
// it's the directory itself, skip
298-
continue;
295+
if (is_array($result['Contents'])) {
296+
foreach ($result['Contents'] as $object) {
297+
if (isset($object['Key']) && $object['Key'] === $path) {
298+
// it's the directory itself, skip
299+
continue;
300+
}
301+
$file = basename(
302+
isset($object['Key']) ? $object['Key'] : $object['Prefix']
303+
);
304+
$files[] = $file;
299305
}
300-
$file = basename(
301-
isset($object['Key']) ? $object['Key'] : $object['Prefix']
302-
);
303-
$files[] = $file;
304306
}
305307
}
306308

0 commit comments

Comments
 (0)