]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix #19066 - Array offset error due to empty file versions array 20449/head
authorLiam JACK <liamjack@users.noreply.github.com>
Sun, 12 Apr 2020 13:35:17 +0000 (15:35 +0200)
committerLiam JACK <liamjack@users.noreply.github.com>
Sun, 12 Apr 2020 13:35:17 +0000 (15:35 +0200)
Signed-off-by: Liam JACK <liamjack@users.noreply.github.com>
apps/files_versions/lib/Storage.php
apps/files_versions/tests/VersioningTest.php

index cb5a02581b5dc60313ce97cb03835878be26cb30..2b896a0cf67481cf28753ed8353344c51acfaae0 100644 (file)
@@ -641,6 +641,11 @@ class Storage {
                }
 
                $firstVersion = reset($versions);
+
+               if ($firstVersion === false) {
+                       return [$toDelete, $size];
+               }
+
                $firstKey = key($versions);
                $prevTimestamp = $firstVersion['version'];
                $nextVersion = $firstVersion['version'] - $step;
index 264295743645ae9385fec8931124975819016f5d..b6d317ea25e66e549f2ed6bd08f1306482d68fd1 100644 (file)
@@ -274,6 +274,11 @@ class VersioningTest extends \Test\TestCase {
                                ],
                                9 // size of all deleted files (every file has the size 1)
                        ],
+                       // fourth set of versions: empty (see issue #19066)
+                       [
+                               [],
+                               0
+                       ]
 
                ];
        }