From 321b56e2b68c2cdded4d9a6a6799a94c43c986ac 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 381aa71a75..d8b3079ff2 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.20180831'; diff --git a/api/setup/tables_update.inc.php b/api/setup/tables_update.inc.php index eeb7639a89..faceb9a689 100644 --- a/api/setup/tables_update.inc.php +++ b/api/setup/tables_update.inc.php @@ -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'; +} + 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