Fix Fatal Error in Album setCollaborator function - redefining computeKey

When calling setCollaborator function two times after another, computeKey is redefined and leads to a fatal error. Fixed by defining it as an anonymous function instead :)

Signed-off-by: Frederik Berg <83548283+frederikb96@users.noreply.github.com>
This commit is contained in:
Frederik Berg 2023-12-18 14:57:55 +01:00
parent bac24f84d5
commit c77b9046a1
1 changed files with 5 additions and 5 deletions

View File

@ -440,12 +440,12 @@ class AlbumMapper {
$existingCollaborators = $this->getCollaborators($albumId);
// Different behavior if type is link to prevent creating multiple link.
function computeKey($c) {
return ($c['type'] === AlbumMapper::TYPE_LINK ? '' : $c['id']).$c['type'];
}
$computeKey = function ($c) {
return ($c['type'] === AlbumMapper::TYPE_LINK ? '' : $c['id']) . $c['type'];
};
$collaboratorsToAdd = array_udiff($collaborators, $existingCollaborators, fn ($a, $b) => strcmp(computeKey($a), computeKey($b)));
$collaboratorsToRemove = array_udiff($existingCollaborators, $collaborators, fn ($a, $b) => strcmp(computeKey($a), computeKey($b)));
$collaboratorsToAdd = array_udiff($collaborators, $existingCollaborators, fn ($a, $b) => strcmp($computeKey($a), $computeKey($b)));
$collaboratorsToRemove = array_udiff($existingCollaborators, $collaborators, fn ($a, $b) => strcmp($computeKey($a), $computeKey($b)));
$this->connection->beginTransaction();