Skip to content

Commit

Permalink
album_disk data not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlan-00 committed Oct 20, 2023
1 parent fc3f105 commit 1f2183e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Repository/Model/AlbumDisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,21 @@ public function isNew(): bool
* @param int $album_id
* @param int $disk
* @param int $catalog
* @param string|null $disksubtitle
*/
public static function check($album_id, $disk, $catalog)
public static function check($album_id, $disk, $catalog, $disksubtitle)
{
// create the album_disk (if missing)
$sql = "INSERT IGNORE INTO `album_disk` (`album_id`, `disk`, `catalog`) VALUES(?, ?, ?)";
Dba::write($sql, array($album_id, $disk, $catalog));
// count a new song on the disk right away
$sql = "UPDATE `album_disk` SET `song_count` = `song_count` + 1 WHERE `album_id` = ? AND `disk` = ? AND `catalog` = ?";
Dba::write($sql, array($album_id, $disk, $catalog));
if (!empty($disksubtitle)) {
// set the subtitle on insert too
$sql = "UPDATE `album_disk` SET `disksubtitle` = ? WHERE `album_id` = ? AND `disk` = ? AND `catalog` = ?";
Dba::write($sql, array($disksubtitle, $album_id, $disk, $catalog));
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/Model/Song.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public static function insert(array $results)
$artist_mbid = $results['mb_artistid'];
$albumartist_mbid = $results['mb_albumartistid'];
$disk = (Album::sanitize_disk($results['disk']) > 0) ? Album::sanitize_disk($results['disk']) : 1;
$disksubtitle = $results['disksubtitle'];
$disksubtitle = $results['disksubtitle'] ?? null;
$year = Catalog::normalize_year($results['year'] ?? 0);
$comment = $results['comment'];
$tags = $results['genre']; // multiple genre support makes this an array
Expand Down Expand Up @@ -556,7 +556,7 @@ public static function insert(array $results)
$artists = array((int)$artist_id, (int)$albumartist_id);

// create the album_disk (if missing)
AlbumDisk::check($album_id, $disk, $catalog);
AlbumDisk::check($album_id, $disk, $catalog, $disksubtitle);

// map the song to catalog album and artist maps
Catalog::update_map((int)$catalog, 'song', $song_id);
Expand Down

0 comments on commit 1f2183e

Please sign in to comment.