Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Slim/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2007,12 +2007,23 @@ sub updateOrCreateBase {
# Update timestamp
$attributeHash->{updated_time} = time();

my $nullableColumns = {
performance => 1,
grouping => 1,
discsubtitle => 1,
musicbrainz_id => 1,
};
# Some taggers will not supply blank tags so create the attributes for columns which need to be nulled.
foreach my $col (keys %$nullableColumns) {
$attributeHash->{uc($col)} = undef if !exists $attributeHash->{uc($col)};
}

while (my ($key, $val) = each %$attributeHash) {

$key = lc($key);

## Need to set performance/grouping/discsubtitle to null if no value passed in (may have had a value before this scan)
if ( (defined $val && $val ne '' || $key eq "performance" || $key eq "grouping" || $key eq "discsubtitle") && exists $trackAttrs->{$key} ) {
# Some columns should be set to null if no value passed in (may have had a value before this scan)
if ( (defined $val && $val ne '' || $nullableColumns->{$key}) && exists $trackAttrs->{$key} ) {

# Bug 7731, filter out duplicate keys that end up as array refs
# https://github.com/LMS-Community/slimserver/issues/1378
Expand All @@ -2024,13 +2035,14 @@ sub updateOrCreateBase {
}

# Metadata is only included if it contains a non zero value
if ( main::STATISTICS && $val && blessed($trackPersistent) && exists $trackPersistentAttrs->{$key} ) {
if ( main::STATISTICS && ($val || $nullableColumns->{$key}) && blessed($trackPersistent) && exists $trackPersistentAttrs->{$key} ) {

main::INFOLOG && $log->is_info && $log->info("Updating persistent $url : $key to $val");

$trackPersistent->set_column( $key => $val );
}
}
$trackPersistent->update() if blessed($trackPersistent);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't call update() before. Would that mean that we never even wrote back those updated values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned above, presumably, unless behaviour has changed in the underlying libraries.

I think probably it's never worked.


# _postCheckAttributes does an update
if (!$playlist) {
Expand Down