From ff3d47435b7084d7844413f5869ef00fce9d434f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 14 Sep 2018 14:01:16 +0200 Subject: [PATCH] * 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" --- api/setup/setup.inc.php | 2 +- api/setup/tables_update.inc.php | 15 +++++++++++++++ setup/inc/class.setup.inc.php | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/api/setup/setup.inc.php b/api/setup/setup.inc.php index c38de666ad..bc9325527e 100644 --- a/api/setup/setup.inc.php +++ b/api/setup/setup.inc.php @@ -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.20181018'; diff --git a/api/setup/tables_update.inc.php b/api/setup/tables_update.inc.php index 8513561fa3..866194f7c0 100644 --- a/api/setup/tables_update.inc.php +++ b/api/setup/tables_update.inc.php @@ -484,3 +484,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'; +} + diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index 3ef7d460e4..8a888d45c0 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -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