* Addressbook: private addressbook in newer installations could not be enabled

caused by forced preference value of false casted to string as "", now we write all forced and default preferences with value false as "0" AND update all forced preferences only from "" to "0"
This commit is contained in:
Ralf Becker 2018-09-14 14:01:16 +02:00
parent cabbacf229
commit 321b56e2b6
3 changed files with 18 additions and 3 deletions

View File

@ -11,7 +11,7 @@
/* Basic information about this app */
$setup_info['api']['name'] = 'api';
$setup_info['api']['title'] = 'EGroupware API';
$setup_info['api']['version'] = '17.1.003';
$setup_info['api']['version'] = '17.1.004';
$setup_info['api']['versions']['current_header'] = '1.29';
// maintenance release in sync with changelog in doc/rpm-build/debian.changes
$setup_info['api']['versions']['maintenance_release'] = '17.1.20180831';

View File

@ -453,3 +453,18 @@ function api_upgrade17_1_002()
return $GLOBALS['setup_info']['api']['currentver'] = '17.1.003';
}
/**
* Fix forced preferences with value '' (casted to from false) to '0' eg. addressbook:private_addressbook
*
* Forced preferences with value '' behave unexpected, false values of type "check" need to be written as "0".
*
* @return type
*/
function api_upgrade17_1_003()
{
Api\Preferences::change_preference(null, '/.*/', '0', '', 'forced');
return $GLOBALS['setup_info']['api']['currentver'] = '17.1.004';
}

View File

@ -744,11 +744,11 @@ class setup
{
if (isset($setting['default']))
{
$default[$name] = (string)$setting['default'];
$default[$name] = $setting['default'] === false && $setting['type'] === 'check' ? '0' : (string)$setting['default'];
}
if (isset($setting['forced']))
{
$forced[$name] = (string)$setting['forced'];
$forced[$name] = $setting['forced'] === false && $setting['type'] === 'check' ? '0' : (string)$setting['forced'];
}
}
// store default/forced preferences, if any found