diff --git a/lib/Listener/AlbumsManagementEventListener.php b/lib/Listener/AlbumsManagementEventListener.php index 949823676..292fce0f9 100644 --- a/lib/Listener/AlbumsManagementEventListener.php +++ b/lib/Listener/AlbumsManagementEventListener.php @@ -49,11 +49,13 @@ public function handle(Event $event): void { } } elseif ($event instanceof ShareDeletedEvent) { $receiverId = $event->getShare()->getSharedWith(); - $this->forEachSubNode( - $event->getShare()->getNode(), - // Remove node from any album when the owner is $receiverId. - fn ($node) => $this->albumMapper->removeFileWithOwner($node->getId(), $receiverId), - ); + if ($receiverId !== null) { // null for public link shares + $this->forEachSubNode( + $event->getShare()->getNode(), + // Remove node from any album when the owner is $receiverId. + fn ($node) => $this->albumMapper->removeFileWithOwner($node->getId(), $receiverId), + ); + } } elseif ($event instanceof UserRemovedEvent) { // Get all shared albums for this group: $albums_group = $this->albumMapper->getSharedAlbumsForCollaborator($event->getGroup()->getGID(), AlbumMapper::TYPE_GROUP);