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

Refactor: prevent DonationFormRepository::prepareQuery() to return forms without the "formBuilderSettings" and "formBuilderFields" meta keys #7392

Merged
merged 1 commit into from
May 20, 2024

Conversation

glaubersilva
Copy link
Contributor

@glaubersilva glaubersilva commented May 17, 2024

Description

All forms created using the visual form builder include the formBuilderSettings and formBuilderFields meta keys since the Give 3.0.0 version, and the DonationForm model relies on these meta keys to work properly.

However, the DonationFormRepository::prepareQuery() method was returning posts even when these meta keys were empty which can throw fatal errors.

Even though this is not a common situation as forms are always created with these meta keys, unforeseen events like accidental deletions made directly through DB can happen.

So this PR prevents returning posts without these meta keys focusing more on a defensive approach that can avoid future problems if they happen.

To better context: my logic here is that as we are relying on this meta key in the isV3Form() method to define if a form is V3 or not, I believe the DonationFormRepository::prepareQuery() also should consider it and not return forms without it.

Affects

The DonationFormRepository::prepareQuery() method.

Testing Instructions

In your terminal, run the following commands:

composer test -- --filter TestDonationFormRepository::testShouldNotReturnDonationFormWithoutSettingsMetaKey
composer test -- --filter TestDonationFormRepository::testShouldNotReturnDonationFormWithoutFieldsMetaKey

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@glaubersilva glaubersilva changed the title Refactor: Prevent returning forms without the "formBuilderSettings" and "formBuilderFields" meta keys Refactor: prevent DonationFormRepository::prepareQuery() to return forms without the "formBuilderSettings" and "formBuilderFields" meta keys May 17, 2024
@glaubersilva glaubersilva self-assigned this May 17, 2024
@glaubersilva glaubersilva marked this pull request as ready for review May 17, 2024 20:11
@glaubersilva glaubersilva requested a review from jonwaldstein May 17, 2024 20:12
@jonwaldstein jonwaldstein requested a review from alaca May 17, 2024 21:19
Copy link
Member

@alaca alaca left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@glaubersilva glaubersilva removed the request for review from jonwaldstein May 20, 2024 12:58
@glaubersilva glaubersilva merged commit 11e183e into develop May 20, 2024
20 checks passed
@glaubersilva glaubersilva deleted the refactor/donation-form-prepare-query branch May 20, 2024 19:20
kjohnson pushed a commit that referenced this pull request Aug 21, 2024
…rms without the "formBuilderSettings" and "formBuilderFields" meta keys (#7392)
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