diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 3f4ccf7f0a2a7e3fc4b792147c180a89bd0ae7ed..147edeb6726d623218eb3c5da942cdf9de15a3eb 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -496,7 +496,7 @@ class Storage {
 		$expiration = self::getExpiration();
 		$threshold = $expiration->getMaxAgeAsTimestamp();
 		$versions = self::getAllVersions($uid);
-		if (!$threshold || !array_key_exists('all', $versions)) {
+		if (!$threshold || empty($versions['all'])) {
 			return;
 		}
 
@@ -578,7 +578,10 @@ class Storage {
 		// newest version first
 		krsort($versions);
 
-		$result = [];
+		$result = [
+			'all' => [],
+			'by_file' => [],
+		];
 
 		foreach ($versions as $key => $value) {
 			$size = $view->filesize(self::VERSIONS_ROOT.'/'.$value['path'].'.v'.$value['timestamp']);
@@ -775,7 +778,7 @@ class Storage {
 
 			// if still not enough free space we rearrange the versions from all files
 			if ($availableSpace <= 0) {
-				$result = Storage::getAllVersions($uid);
+				$result = self::getAllVersions($uid);
 				$allVersions = $result['all'];
 
 				foreach ($result['by_file'] as $versions) {