Skip to content

Commit 65bb120

Browse files
lanxenetMorrisJobke
authored andcommitted
fix(AmazonS3): fix loop $result['Contents'] error
Invalid argument supplied for foreach() at /var/www/html/apps/files_external/lib/Lib/Storage/AmazonS3.php#295
1 parent af2ecbb commit 65bb120

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)