Skip to content

Commit

Permalink
Fix #19066 - Array offset error due to empty file versions array
Browse files Browse the repository at this point in the history
Signed-off-by: Liam JACK <liamjack@users.noreply.github.com>
  • Loading branch information
liamjack committed Apr 12, 2020
1 parent 8924214 commit b6c76f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,11 @@ protected static function getAutoExpireList($time, $versions) {
}

$firstVersion = reset($versions);

if ($firstVersion === false) {
return [$toDelete, $size];
}

$firstKey = key($versions);
$prevTimestamp = $firstVersion['version'];
$nextVersion = $firstVersion['version'] - $step;
Expand Down
5 changes: 5 additions & 0 deletions apps/files_versions/tests/VersioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public function versionsProvider() {
],
9 // size of all deleted files (every file has the size 1)
],
// fourth set of versions: empty (see issue #19066)
[
[],
0
]

];
}
Expand Down

0 comments on commit b6c76f4

Please sign in to comment.