From: Pratik Joshi Date: Tue, 9 Apr 2013 16:25:46 +0000 (+0530) Subject: CRM-12273 minor QA for some DB state observed after upgrade after checking PR 323 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ab44179e3a126048f42730920d194ca2ba17dc95;p=civicrm-core.git CRM-12273 minor QA for some DB state observed after upgrade after checking PR 323 --- diff --git a/CRM/Upgrade/Incremental/php/FourTwo.php b/CRM/Upgrade/Incremental/php/FourTwo.php index 943c3ba20d..6630ac122c 100644 --- a/CRM/Upgrade/Incremental/php/FourTwo.php +++ b/CRM/Upgrade/Incremental/php/FourTwo.php @@ -443,6 +443,11 @@ WHERE cpse.price_set_id IS NULL"; if (empty($optionValue)) return; } + elseif (!CRM_Utils_Array::value('otherAmount', $options) && !CRM_Utils_Array::value('membership', $options)) { + //CRM-12273 + //if options group, otherAmount, membersip is empty then return, contribution should be default price set + return; + } if (! CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', true)) { $setParams['name'] = $pageTitle; @@ -629,8 +634,23 @@ WHERE cpf.price_set_id = %1 } else { $sql .= "AND cpfv.amount = %2"; + + //CRM-12273 + //check if price_set_id is exist, if not use the default contribution amount + if (isset($result->price_set_id)){ + $priceSetId = $result->price_set_id; + } + else{ + $defaultPriceSets = CRM_Price_BAO_Set::getDefaultPriceSet(); + foreach ($defaultPriceSets as $key => $pSet) { + if ($pSet['name'] == 'contribution_amount'){ + $priceSetId = $pSet['setID']; + } + } + } + $params = array( - '1' => array($result->price_set_id, 'Integer'), + '1' => array($priceSetId, 'Integer'), '2' => array($result->total_amount, 'String'), ); $res = CRM_Core_DAO::executeQuery($sql, $params); @@ -647,7 +667,7 @@ WHERE cpf.price_set_id = %1 } else { $params = array( - 'price_set_id' => $result->price_set_id, + 'price_set_id' => $priceSetId, 'name' => 'other_amount', ); $defaults = array(); @@ -660,7 +680,7 @@ WHERE cpf.price_set_id = %1 } else { $lineParams['price_field_id'] = - CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id'); + CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $priceSetId, 'id', 'price_set_id'); $lineParams['label'] = 'Contribution Amount'; } $lineParams['qty'] = 1;