-
Notifications
You must be signed in to change notification settings - Fork 194
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: prevent fatal error during form migration #7197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pauloiankoski I left a few comments suggesting changes in the conditions to make sure it will work with arrays.
Another solution would be to handle this problem inside the getFundsAndDesignationsAttributes()
method.
If you take a look at line 650
, you will see this: $options[0]
The problem here is that the index 0
of the $options
var may not exist in certain scenarios, we can return an empty array instead of a null value. We also can return an empty array in the 651
line instead of a null value.
@glaubersilva What's the practical difference between I implemented with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pauloiankoski You are right. Seems that this is some internalized practice by me too many years ago that does not make sense anymore...
I remember that at some point in the past, I had some kind of problem using the empty()
method with arrays (maybe with some old PHP version - not sure), so I set it in my mind to always use the count()
method to prevent any problems.
But to be honest, revisiting it now I can't remember or reproduce any problem using it. This way, I believe we are ready to QA.
Thanks for the discussion!
About the fatal error during the migration, I wasn't able to reproduce it locally using the PHP 7.4.30
version. So if it was happening only in specific versions, we need to inform the QA team which version should be used to test this fix.
Thank you, @glaubersilva zito! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed manual QA tests.
Resolves GIVE-243
Description
After version 3.3.0, form migrations began to fail with a fatal error. Upon investigation, I discovered that under certain conditions, the conditionals for executing the Funds & Designations step were attempting to count the elements of a nullable variable, resulting in the fatal error.
This pull request resolves the issue by replacing the
count
function with an!empty
check. This fix will work for both nullable variables (returning false) and arrays.Affects
Form Migrations
Testing Instructions
Pre-review Checklist
@unreleased
tags included in DocBlocks