diff --git a/lib/Controller/Library.php b/lib/Controller/Library.php index 2a7b1c4808..1e7caaa856 100644 --- a/lib/Controller/Library.php +++ b/lib/Controller/Library.php @@ -2731,6 +2731,10 @@ public function selectFolder(Request $request, Response $response, $id) $media->save(['saveTags' => false]); + if ($media->parentId != 0) { + $this->updateMediaRevision($media, $folderId); + } + // Return $this->getState()->hydrate([ 'httpStatus' => 204, @@ -2901,4 +2905,19 @@ private function hasFullScreenLayout(Media $media): ?int { return $this->layoutFactory->getLinkedFullScreenLayout('media', $media->mediaId)?->campaignId; } + + /** + * Update media files with revisions + * @param Media $media + * @param $folderId + */ + private function updateMediaRevision(Media $media, $folderId) + { + $oldMedia = $this->mediaFactory->getParentById($media->mediaId); + $oldMedia->folderId = $folderId; + $folder = $this->folderFactory->getById($oldMedia->folderId); + $folder->permissionsFolderId = ($folder->getPermissionFolderId() == null) ? $folder->id : $folder->getPermissionFolderId(); + + $oldMedia->save(['saveTags' => false, 'validate' => false]); + } }