Refactor: prevent DonationFormRepository::prepareQuery() to return forms without the "formBuilderSettings" and "formBuilderFields" meta keys #7392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
All forms created using the visual form builder include the
formBuilderSettings
andformBuilderFields
meta keys since the Give 3.0.0 version, and theDonationForm
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:
Pre-review Checklist
@unreleased
tags included in DocBlocks