Skip to content

CIWEMB-635: Fix membership form using wrong price set during submission#209

Merged
erawat merged 1 commit into5.75.0-patchesfrom
CIWEMB-635-5.75.0-patch
Apr 10, 2026
Merged

CIWEMB-635: Fix membership form using wrong price set during submission#209
erawat merged 1 commit into5.75.0-patchesfrom
CIWEMB-635-5.75.0-patch

Conversation

@erawat
Copy link
Copy Markdown
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. getPriceSetID() falls back to the default quick-config price set instead of the one selected by the user, causing membership_type_id to be missing from the INSERT.

Core PR: civicrm#35144

Patch commit

CIWEMB-635: Fix membership form using wrong price set during submission
PR: https://github.com/civicrm/civicrm-core/pull/35144

@gemini-code-assist
Copy link
Copy Markdown

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 creation process within the back-office form. Previously, when a non-quick-config price set was selected, the system would incorrectly revert to a default price set during submission, causing a database constraint violation due to missing membership_type_id. The changes ensure that the user's chosen price set is correctly identified and used, preventing these errors and improving the reliability of membership creation.

Highlights

  • Membership Form Price Set Correction: Resolved an issue where the membership form incorrectly used a default quick-config price set instead of the user-selected one during submission, leading to database constraint violations.
  • Robust Price Set Retrieval: Implemented a fallback mechanism to directly retrieve the price_set_id from raw POST data if getSubmittedValue() returns NULL, ensuring the correct price set is always respected.
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
Copy Markdown

@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

The pull request aims to fix a bug where the wrong price set was being used on a membership form. The change adds a fallback to read the price set ID directly from the POST data. While the fix is logically correct, it introduces a direct access to the $_POST superglobal, which is a security concern and against best practices. My review includes a suggestion to use the framework's CRM_Utils_Request::retrieve utility instead, which is safer and more idiomatic for this codebase.

Comment thread CRM/Member/Form.php Outdated
Comment on lines +569 to +571
if (!$this->_priceSetId && !empty($_POST['price_set_id'])) {
$this->_priceSetId = (int) $_POST['price_set_id'];
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Directly accessing superglobals like $_POST is discouraged as it can bypass framework-level validation and sanitization, posing a potential security risk. It's better to use the framework's utilities for handling request data. In this case, CRM_Utils_Request::retrieve should be used to safely get the value from the POST data. This also avoids a potential bug with empty('0') evaluating to true, which could cause issues if a price set had an ID of 0.

    if (!$this->_priceSetId) {
      $this->_priceSetId = CRM_Utils_Request::retrieve('price_set_id', 'Integer', 'POST', FALSE);
    }

@erawat erawat force-pushed the CIWEMB-635-5.75.0-patch branch from 94c8ebc to e5c7be8 Compare March 19, 2026 12:31
@erawat erawat merged commit 1c033b6 into 5.75.0-patches Apr 10, 2026
@erawat erawat deleted the CIWEMB-635-5.75.0-patch branch April 10, 2026 15:23
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