Skip to content

Conversation

@barryvdh
Copy link
Contributor

@barryvdh barryvdh commented Feb 9, 2018

Description

When a empty configuration file is ready, this could result in loading invalid configuration, eg. just 1 instead 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

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Feb 9, 2018

CLA assistant check
All committers have signed the CLA.

@orlangur orlangur self-assigned this Feb 9, 2018
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better?

@magento-engcom-team
Copy link
Contributor

@barryvdh thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

Copy link
Contributor

@orlangur orlangur left a 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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, done and done.

@magento-engcom-team magento-engcom-team merged commit 6cc625f into magento:2.2-develop Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants