Skip to content

CIWEMB-635: Fix stale membership_type_id overriding price set selections on membership form#210

Open
erawat wants to merge 1 commit into6.4.1-patchesfrom
CIWEMB-635-6.4.1-patch
Open

CIWEMB-635: Fix stale membership_type_id overriding price set selections on membership form#210
erawat wants to merge 1 commit into6.4.1-patchesfrom
CIWEMB-635-6.4.1-patch

Conversation

@erawat
Copy link
Member

@erawat erawat commented Mar 19, 2026

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_id from the org/type selector overrides the price set selections, causing membership_type_id to be missing from the INSERT.

Core PR: civicrm#35145

Patch commit

CIWEMB-635: Fix stale membership_type_id overriding price set selections on membership form
PR: https://github.com/civicrm/civicrm-core/pull/35145

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • Membership Form Logic: Corrected an issue where a stale membership_type_id could override price set selections on the back-office membership form, leading to a database constraint violation.
  • Database Integrity: Ensured that the membership_type_id is correctly determined, preventing its absence during an INSERT operation when using non-quick-config price sets.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'])) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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'])) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants