-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Ensure DeploymentConfig Reader always returns an array #13584
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
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.
What do you think about throwing an exception instead of silently ignoring an invalid configuration files?
I mean, right after the configuration file inclusion.
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.
But that would still block the deployment process as described in #13090
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.
The current behavior when $fileKey is empty is actually also silently ignoring invalid files: https://github.com/barryvdh/magento2/blob/e4d857fe63717d24da7b3fbeaa44504fcd866632/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php#L115
So this would bring it inline with that behaviour.
Or do you want me to add check after both includes to throw an exception?
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.
It's fine to block deployment process in case of invalid data provided. Otherwise it would be pretty nontrivial to debug what went wrong.
Yeah, looks like is_array was randomly introduced in barryvdh@02596b7#diff-db4cf46912b0aad3f54619ff946b9ac8R115, please throw proper exception in both cases when file data is invalid.
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.
Better?
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.
Hi @barryvdh, logic looks perfect to me now, just a small cosmetic changes left.
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.
Please add corresponding @throws line into method PHPDoc.
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.
Please replace to an equivalent if ($fileData). As always, please squash changes into a single commit.
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.
Done, done and done.
Throw exception on invalid config
Description
When a empty configuration file is ready, this could result in loading invalid configuration, eg. just
1instead of an array. This will lead to problems with other code, expecting a valid array.Fixed Issues
/pull/13090
Manual testing scenarios
Create an empty file as app/etc/env.php and run the CLI installer