Skip to content

Commit

Permalink
Merge pull request #2205 from frederikb96/patch-1
Browse files Browse the repository at this point in the history
Fix Fatal Error in Album setCollaborator function - redefining computeKey function
  • Loading branch information
artonge authored Jan 25, 2024
2 parents bac24f8 + c77b904 commit 3d93169
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Album/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ public function setCollaborators(int $albumId, array $collaborators): void {
$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();

Expand Down

0 comments on commit 3d93169

Please sign in to comment.