diff options
author | enoch <lanxenet@hotmail.com> | 2018-03-16 11:51:27 +0800 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-05-29 15:03:28 +0200 |
commit | 65bb12032d263e1449f0058886261cf2ac8a2a59 (patch) | |
tree | 16cf2a5f4ee44c2f73739da03bd846c977bd2176 /apps | |
parent | af2ecbbd5a81d8e1621ecda1784a99adb0fc43dd (diff) | |
download | nextcloud-server-65bb12032d263e1449f0058886261cf2ac8a2a59.tar.gz nextcloud-server-65bb12032d263e1449f0058886261cf2ac8a2a59.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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/AmazonS3.php | 18 |
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 cc9cdc08138..cf79e05c9c3 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -292,15 +292,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; } } |