Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2816: New contribution can't be saved when validation fails … #21512

Merged
merged 1 commit into from
Sep 17, 2021

Conversation

monishdeb
Copy link
Member

Overview

Steps to replicate:

  1. Define a premium product.
  2. Contributions - New Contribution
  3. Fill out the contact and the amount, but forget, let's say, the financial type.
  4. Click save.
  5. Ok it warns you and reloads the form.
  6. Now pick Donation.
  7. Click save.

Before

before

After

after

Technical Details

Regression is caused in 'New Contribution' backoffice form from 5.40 onward, when civicrm_contribution_product.product_id is set as a foreignkey of civicrm_product.id here. As a result the previously code used to insert product_id = 0 for back office contribution and now it ends up in a DB error due to nonexistent product_id = 0. Rest assured this doesn't break CiviCRM upgrade from 5.40 onward because of this DELETE SQL here which also delete entries with non-existent product_ids.

As per the fix is concern, I am not in support of changing the placeholder - select - value to '' from 0, because 0 serves as an indicator on the backoffice contribution edit screen, when one removes the previous product selection.

Comments

ping @eileenmcnaughton @seamuslee001 @colemanw

@civibot
Copy link

civibot bot commented Sep 17, 2021

(Standard links)

$ContributionProduct = new CRM_Contribute_DAO_ContributionProduct();
$ContributionProduct->id = $premiumID;
$ContributionProduct->contribution_id = $contributionID;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is ok because the UI only supports one premium per contribution.

@demeritcowboy
Copy link
Contributor

Runs ok for me.

@demeritcowboy demeritcowboy merged commit b940460 into civicrm:5.42 Sep 17, 2021
@eileenmcnaughton
Copy link
Contributor

Thanks @monishdeb @demeritcowboy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants