Skip to content

Commit

Permalink
Layout import : Fix Playlist closure table. (#2780)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis authored Oct 25, 2024
1 parent 1cd1035 commit 73173df
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions lib/Entity/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2681,29 +2681,34 @@ public function managePlaylistClosureTable()
$child = $assignedPlaylistIds;
}
}
}
}

if (isset($parentId) && isset($child)) {
foreach ($child as $childId) {
$this->getLog()->debug('Manage closure table for parent ' . $parentId . ' and child ' . $childId);

if ($this->getStore()->exists('SELECT parentId, childId, depth FROM lkplaylistplaylist WHERE childId = :childId AND parentId = :parentId ', [//phpcs:ignore
'parentId' => $parentId,
'childId' => $childId
])) {
throw new InvalidArgumentException(__('Cannot add the same SubPlaylist twice.'), 'playlistId');
}
if (isset($parentId) && isset($child)) {
foreach ($child as $childId) {
$this->getLog()->debug(
'Manage closure table for parent ' . $parentId . ' and child ' . $childId
);

if ($this->getStore()->exists('SELECT parentId, childId, depth FROM lkplaylistplaylist WHERE childId = :childId AND parentId = :parentId ', [//phpcs:ignore
'parentId' => $parentId,
'childId' => $childId
])) {
throw new InvalidArgumentException(
__('Cannot add the same SubPlaylist twice.'),
'playlistId'
);
}

$this->getStore()->insert('
$this->getStore()->insert('
INSERT INTO `lkplaylistplaylist` (parentId, childId, depth)
SELECT p.parentId, c.childId, p.depth + c.depth + 1
FROM lkplaylistplaylist p, lkplaylistplaylist c
WHERE p.childId = :parentId AND c.parentId = :childId
', [
'parentId' => $parentId,
'childId' => $childId
]);
'parentId' => $parentId,
'childId' => $childId
]);
}
}
}
}
}
Expand Down

0 comments on commit 73173df

Please sign in to comment.