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

[Fix] Do not modify current list of countries with require states during setup upgrade #16885

Merged
merged 3 commits into from Sep 28, 2018

Conversation

jalogut
Copy link
Contributor

@jalogut jalogut commented Jul 17, 2018

Upgrading from any version <2.2.0 to any version >=2.2.0 results in modifications of general/region/state_required value.

How to reproduce

  • Having a Magento project in any version <2.2.0
  • Set custom values in core_config_data for general/region/state_required
  • Upgrade Magento project to any version >=2.2.0

Expected result

  • general/region/state_required is not modified

Actual result

  • general/region/state_required is overridden with all enabled countries in general/country/allow

Fixed Issues

  • Checkout not working after upgrade for existing users that do no have a state in their address
  • State is a mandatory for all allowed countries which might break other functionalities depending on that (sign up, reset password, customer import...)

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…ing setup upgrade. Also mark getCountriesWithRequiredStates() as deprecated because is no longer needed
@magento-engcom-team
Copy link
Contributor

Hi @jalogut. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@@ -41,10 +41,10 @@ public function __construct(Data $directoryData)
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->addCountryRegions($setup, $this->getDataForCroatia());
$this->addCountryRegions($setup, 'IN', $this->getDataForCroatia());
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe IN and HR should be swapped here

Copy link
Contributor

@dmanners dmanners left a comment

Choose a reason for hiding this comment

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

I have 1 question on this review and there is still one outstanding from FooMan.

@@ -34,10 +34,6 @@
<type name="Magento\Directory\Model\ResourceModel\Country\Collection" shared="false">
<arguments>
<argument name="helperData" xsi:type="object">DirectoryHelperDataProxy</argument>
<argument name="countriesWithNotRequiredStates" xsi:type="array">
<item name="FR" xsi:type="string">FR</item>
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the reasoning behind making this change?

@dmanners
Copy link
Contributor

dmanners commented Sep 5, 2018

Hi @jalogut do you have time to look into the feedback on this pull request?

Thanks

@dmanners dmanners self-assigned this Sep 5, 2018
@jalogut
Copy link
Contributor Author

jalogut commented Sep 6, 2018

Hi, sorry that was a mistake. I updated the PR with some changes. It should be ok now. Thanks for checking.

@dmanners
Copy link
Contributor

During testing we had the following cases fail

I tried to upgrade from 2.2-develop to PR, - "general/region/state_required" is not modified.

When I upgraded from 2.2.3 to PR, - in addition to our value, IN is added to "general/region/state_required".

When upgrading from 2.1-develop to PR, - in addition to our value, HR and IN are added to "general/region/state_required"

@jalogut could you please look at these failures for us.

Thank you.

@jalogut
Copy link
Contributor Author

jalogut commented Sep 19, 2018

What do you mean with failing? That is right behaviour. This setup scripts are depending on the current version of Magento_Directory module.

HR is added on 2.0.1 and IN in 2.0.2

@dmanners
Copy link
Contributor

@jalogut are IN and HR added to "general/region/state_required" in earlier versions? Just going from your description:

general/region/state_required is not modified

If it was reported as a failure as in two cases it is modified.

@jalogut
Copy link
Contributor Author

jalogut commented Sep 20, 2018

Well I meant “do not overwrite current value”. Before this PR, the current value is overwritten with the default magento one. This PR adds the new countries (IN, HR) while keeping previous value. Should I update the PR title?

@dmanners
Copy link
Contributor

Ah I see @jalogut thanks for the clarification.

@magento-engcom-team magento-engcom-team merged commit 875c394 into magento:2.2-develop Sep 28, 2018
magento-engcom-team pushed a commit that referenced this pull request Sep 28, 2018
@magento-engcom-team
Copy link
Contributor

Hi @jalogut. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

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.

None yet

5 participants