From 1f85becb43fc3429ba8efcdbbf5c081b0c991302 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 3 Jul 2018 12:24:09 +1000 Subject: [PATCH] dev/core#227 Fix issue where on some extened groups the multiple records checkbox doesn't show this causes empty string to be passed in which was causing problems when working out if we needed to make changes to the custom value table --- CRM/Core/BAO/CustomGroup.php | 4 +++- tests/phpunit/api/v3/CustomGroupTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 750939cdaa..b26dc9e6a3 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -147,7 +147,9 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'is_multiple' ); - if ($params['is_multiple'] != $isMultiple) { + // dev/core#227 Fix issue where is_multiple in params maybe an empty string if checkbox is not rendered on the form. + $paramsIsMultiple = empty($params['is_multiple']) ? 0 : 1; + if ($paramsIsMultiple != $isMultiple) { $tableNameNeedingIndexUpdate = CRM_Core_DAO::getFieldValue( 'CRM_Core_DAO_CustomGroup', $params['id'], diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index 56f4870f1a..ae67aa8391 100644 --- a/tests/phpunit/api/v3/CustomGroupTest.php +++ b/tests/phpunit/api/v3/CustomGroupTest.php @@ -313,6 +313,15 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { $this->callAPISuccess('CustomGroup', 'create', ['id' => $customGroup['id']]); } + /** + * Test an update when is_multiple is an emtpy string this can occur in form submissions for custom groups that extend activites. + * dev/core#227. + */ + public function testCustomGroupEmptyisMultipleUpdate() { + $customGroup = $this->callAPISuccess('CustomGroup', 'create', array_merge($this->_params, ['is_multiple' => 0])); + $this->callAPISuccess('CustomGroup', 'create', ['id' => $customGroup['id'], 'is_multiple' => '']); + } + /** * Check with Activity - Meeting Type */ -- 2.25.1