CIWEMB-635: Fix stale membership_type_id overriding price set selections on membership form#210
CIWEMB-635: Fix stale membership_type_id overriding price set selections on membership form#210erawat wants to merge 1 commit into6.4.1-patchesfrom
Conversation
…ons on membership form PR: civicrm#35145
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the membership form logic that caused database constraint violations. The fix ensures that when a membership is created using a non-quick-config price set, the system correctly prioritizes the price set selections, preventing a stale membership type ID from being used and ensuring data integrity during the insertion process. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where a stale membership_type_id could override selections made in a price set, leading to database constraint violations. The fix correctly prevents the stale ID from being used when a price_set_id is present. The change is logical and directly solves the described problem. I have one suggestion to improve the robustness of the conditional check.
| $memTypeSelected = []; | ||
| $priceFieldIDS = self::getPriceFieldIDs($params, $priceSet); | ||
| if (isset($params['membership_type_id']) && !empty($params['membership_type_id'][1])) { | ||
| if (isset($params['membership_type_id']) && !empty($params['membership_type_id'][1]) && empty($params['price_set_id'])) { |
There was a problem hiding this comment.
For improved code robustness and clarity, it's better to explicitly check if $params['membership_type_id'] is an array before attempting to access an index on it. Using is_array() instead of isset() prevents potential warnings or unexpected behavior if $params['membership_type_id'] happens to be a non-array type like a string.
if (is_array($params['membership_type_id']) && !empty($params['membership_type_id'][1]) && empty($params['price_set_id'])) {
Summary
Patch for CIWEMB-635: Fixes DB constraint violation when creating membership via non-quick-config price set on the back-office membership form. A stale
membership_type_idfrom the org/type selector overrides the price set selections, causingmembership_type_idto be missing from the INSERT.Core PR: civicrm#35145
Patch commit