Skip to content

Commit

Permalink
Merge pull request #38153 from nextcloud/backport/38125/stable26
Browse files Browse the repository at this point in the history
[stable26] Check if version entity is not null before delete
  • Loading branch information
artonge authored May 10, 2023
2 parents 7083668 + 07b82d7 commit 1229beb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,12 @@ public static function expireOlderThanMaxForUser($uid) {
foreach ($versions as $version) {
$internalPath = $version->getInternalPath();
\OC_Hook::emit('\OCP\Versions', 'preDelete', ['path' => $internalPath, 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]);
$versionsMapper->delete($versionEntities[$version->getId()]);

$versionEntity = $versionEntities[$version->getId()];
if (!is_null($versionEntity)) {
$versionsMapper->delete($versionEntity);
}

$version->delete();
\OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $internalPath, 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]);
}
Expand Down

0 comments on commit 1229beb

Please sign in to comment.