From 13322a1ec3bb341986f3bd948df2712b88b6c89f Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 24 Mar 2015 16:04:28 +0530 Subject: [PATCH] CRM-15908 additional fix ---------------------------------------- * CRM-15908: saved searches that use multi-select custom groups break during 4.4 -> 4.5 upgrade https://issues.civicrm.org/jira/browse/CRM-15908 --- CRM/Upgrade/Incremental/php/FourFive.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourFive.php b/CRM/Upgrade/Incremental/php/FourFive.php index 46a36a30fc..a7f57fc4e8 100755 --- a/CRM/Upgrade/Incremental/php/FourFive.php +++ b/CRM/Upgrade/Incremental/php/FourFive.php @@ -343,7 +343,7 @@ DROP KEY `{$dao->CONSTRAINT_NAME}`"; if (array_key_exists('CiviCRM_OP_OR', $data_value)) { // This indicates data structure identified by jamie in the form: // value1 => 1, value2 => , value3 => 1. - $data_value = array_keys($data_value, 1); + $data_value = array_keys($data_value, 1); // If CiviCRM_OP_OR - change OP from default to OR if($data_value['CiviCRM_OP_OR'] == 1) { @@ -360,14 +360,23 @@ DROP KEY `{$dao->CONSTRAINT_NAME}`"; $op = 'or'; unset($data_value[$key]); } - + + //If only Or operator has been chosen, means we need to select all values and + //so to execute OR operation between these values according to new data structure + if (count($data_value) == 0 && $op == 'or') { + $customOption = CRM_Core_BAO_CustomOption::getCustomOption($fieldID); + foreach ($customOption as $option) { + $data_value[] = CRM_Utils_Array::value('value', $option); + } + } + $formValues[$field] = $data_value; $formValues["${field}_operator"] = $op; } } } - if($update) { + if ($update) { $sql = "UPDATE civicrm_saved_search SET form_values = %0 WHERE id = %1"; CRM_Core_DAO::executeQuery($sql, array( -- 2.25.1