Skip to content

Commit

Permalink
check the array exists on api calls and get_items
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed Apr 10, 2024
1 parent a818a61 commit acf09d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Module/Api/Method/Api4/Playlist4Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public static function playlist(array $input, User $user): bool
// Smartlists
$playlist = new Search((int) str_replace('smart_', '', $list_id), 'song', $user);
}
if ($playlist->isNew()) {
Api4::message('error', T_('Library item not found'), '404', $input['api_format']);

return false;
}
if (!$playlist->type == 'public' && (!$playlist->has_access($user->id) && $user->access !== 100)) {
Api4::message('error', T_('Access denied to this playlist'), '401', $input['api_format']);

Expand Down
5 changes: 5 additions & 0 deletions src/Module/Api/Method/Api4/PlaylistSongs4Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public static function playlist_songs(array $input, User $user): bool
// Smartlists
$playlist = new Search((int) str_replace('smart_', '', $uid), 'song', $user);
}
if ($playlist->isNew()) {
Api4::message('error', T_('Library item not found'), '404', $input['api_format']);

return false;
}
if (!$playlist->type == 'public' && (!$playlist->has_access($user->id) && $user->access !== 100)) {
Api4::message('error', T_('Access denied to this playlist'), '401', $input['api_format']);

Expand Down
3 changes: 3 additions & 0 deletions src/Repository/Model/Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ public function format($details = true): void
*/
public function get_items(): array
{
if ($this->isNew()) {
return array();
}
$results = array();
$user = Core::get_global('user');
$user_id = $user->id ?? 0;
Expand Down

0 comments on commit acf09d7

Please sign in to comment.