Bug 5681 - Settings upgrade of boolean attributes doesn't work if default is On
: Settings upgrade of boolean attributes doesn't work if default is On
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Plugins
: 7.0
: PC Other
: P2 normal (vote)
: ---
Assigned To: Andy Grundman
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-05 15:45 UTC by Erland Isaksson
Modified: 2008-12-18 11:12 UTC (History)
0 users

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erland Isaksson 2007-10-05 15:45:55 UTC
Settings upgrade on boolean attributes doesn't work if default value is On and the old value in 6.5 preferences is Off. As an example this happens in the Random Mix settings.

The problem is migration code that looks like this:
=====================
$prefs->migrate(1, sub {
        $prefs->set('newtracks', Slim::Utils::Prefs::OldPrefs->get('plugin_random_number_of_tracks')     || 10 );
        $prefs->set('oldtracks', Slim::Utils::Prefs::OldPrefs->get('plugin_random_number_of_old_tracks') || 0  );
        $prefs->set('continuous',  Slim::Utils::Prefs::OldPrefs->get('plugin_random_keep_adding_tracks')   || 1  );
        $prefs->set('exclude_genres', Slim::Utils::Prefs::OldPrefs->get('plugin_random_exclude_genres')  || [] );
        1;
});
=====================

The result is that if 'plugin_random_keep_adding_tracks' is 0 before the upgrade the code above will set 'continuous' to 1 after the upgrade. The 'plugin_random_number_of_old_tracks' property will work correctly since its default value is set to 0.

The Random Mix plugin is one place where migration code like this exist, but I suspect the same problem might also exist in other places.
Comment 1 Chris Owens 2007-11-01 11:18:27 UTC
Andy says this will be fixed when we move to perl 5.10 or higher.  
Comment 2 Andy Grundman 2007-11-01 11:24:54 UTC
Not really, it will be fixed now it just requires a bit more code. :)
Comment 3 Andy Grundman 2007-11-09 09:44:20 UTC
Fixed in change 14552.
Comment 4 Chris Owens 2008-03-07 09:03:16 UTC
This bug is being closed since it was resolved for a version which is now released!  Please download the new version of SqueezeCenter (formerly SlimServer) at http://www.slimdevices.com/su_downloads.html

If you are still seeing this bug, please re-open it and we will consider it for a future release.