]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix undefined index and consequential damages in versions code
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 8 Oct 2020 17:52:29 +0000 (19:52 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 13 Oct 2020 15:39:32 +0000 (15:39 +0000)
If the user has no space and there are no versions, there won't be an
`all` index in the versions entry. Hence this triggers a warning and
becomes `null`, afterwards `count`, `foreach` and friends will happily
throw even more warnings and errors because they don't want to play with
`null`. Thus adding a fallback to an empty array.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/files_versions/lib/Storage.php

index a83ec3488270f7558000d882509df27f020f71da..04bfa1c7c3ff4222bb1e6df8d3ca4b3a0752ea5c 100644 (file)
@@ -776,7 +776,7 @@ class Storage {
                        // if still not enough free space we rearrange the versions from all files
                        if ($availableSpace <= 0) {
                                $result = Storage::getAllVersions($uid);
-                               $allVersions = $result['all'];
+                               $allVersions = $result['all'] ?? [];
 
                                foreach ($result['by_file'] as $versions) {
                                        list($toDeleteNew, $size) = self::getExpireList($time, $versions, $availableSpace <= 0);