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

Fix: duplicate meta keys #7131

Merged
merged 8 commits into from
Dec 19, 2023
Merged

Fix: duplicate meta keys #7131

merged 8 commits into from
Dec 19, 2023

Conversation

alaca
Copy link
Member

@alaca alaca commented Dec 6, 2023

Resolves GIVE-137

Description

This PR resolves the issue of duplicate donation forms. The problem was in the logic of the get_earnings method combined with the donation transfer logic which resulted in the meta key being duplicated on every page load. That also affected the donation forms list table which was displaying duplicated results.

The issue is resolved by using update_post_meta instead of add_post_meta function, and by adding a migration for deleting duplicated meta keys (_give_form_earnings, _give_form_sales) and setting the correct values for _give_form_earnings is added.

Affects

Donation Forms list table
Donation Form data transfer

Testing Instructions

The best way to test this is on an existing site that has this problem.

Create a new site by using Local or something similar.
Install All-In-On WP Migration plugin.
Download the site backup and import it (https://drive.google.com/file/d/16SIlaCQ-1nMvneFpYvdLStA2_ovtQ6vG/view?usp=sharing).
After import, verify that the problem exists by checking the donation forms list table, or even better by querying the give_formmeta table. Something like:

select form_id, meta_key from wp_give_formmeta where form_id = FORM_ID and ( meta_key = '_give_form_sales' or  meta_key = '_give_form_earnings');

Now delete or disable the existing Give plugin and install Give from GitHub repo.
Switch to this branch fix/duplicate-meta-keys
Check the donation forms list table.

Pre-review Checklist

  • Relevant @unreleased tags included in DocBlocks
  • Self Review of code and UX completed

@alaca alaca marked this pull request as draft December 6, 2023 15:17
@jonwaldstein
Copy link
Contributor

@alaca should we also update TransferDonations.php - so that we're falling back on 0 revenue when empty?

Screenshot 2023-12-06 at 10 57 51 AM

@alaca
Copy link
Member Author

alaca commented Dec 7, 2023

@jonwaldstein good catch. Although it's not necessary, we should probably update it. Resolved!

@alaca alaca marked this pull request as ready for review December 7, 2023 09:25
Copy link
Contributor

@jonwaldstein jonwaldstein left a comment

Choose a reason for hiding this comment

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

@alaca great job! ready for QA 🌈

Copy link
Member

@rickalday rickalday left a comment

Choose a reason for hiding this comment

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

Passed manual QA test

@alaca alaca merged commit e11fe2c into develop Dec 19, 2023
20 checks passed
@alaca alaca deleted the fix/duplicate-meta-keys branch December 19, 2023 23:48
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.

4 participants