summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenoch <lanxenet@hotmail.com>2018-03-16 11:51:27 +0800
committerGitHub <noreply@github.com>2018-03-16 11:51:27 +0800
commit6212992c0a030a4768a217cc2b1fb93931e7ffdd (patch)
treeee6b4cda464f9bbc4c2dc5176567e69ca92f55bd
parentb7e7ae5d6d95af8e84f27f90e78d14bfd6e156b5 (diff)
downloadnextcloud-server-6212992c0a030a4768a217cc2b1fb93931e7ffdd.tar.gz
nextcloud-server-6212992c0a030a4768a217cc2b1fb93931e7ffdd.zip
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
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php18
1 files changed, 10 insertions, 8 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 553e5316333..e9986f45c6c 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -291,15 +291,17 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$files[] = substr(trim($prefix['Prefix'], '/'), strlen($path));
}
}
- foreach ($result['Contents'] as $object) {
- if (isset($object['Key']) && $object['Key'] === $path) {
- // it's the directory itself, skip
- continue;
+ if (is_array($result['Contents'])) {
+ foreach ($result['Contents'] as $object) {
+ if (isset($object['Key']) && $object['Key'] === $path) {
+ // it's the directory itself, skip
+ continue;
+ }
+ $file = basename(
+ isset($object['Key']) ? $object['Key'] : $object['Prefix']
+ );
+ $files[] = $file;
}
- $file = basename(
- isset($object['Key']) ? $object['Key'] : $object['Prefix']
- );
- $files[] = $file;
}
}