Magento2: Cannot restore config value from store view scope using "Use website" checkbox.

Created on 6 Feb 2020  路  15Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento >=2.2

Steps to reproduce (*)

  1. Uncheck "Use website" and set specific setting at store view level, save config.
  2. Check "Use website" and save config.

Expected result (*)

  1. delete value from table core_config_data

Actual result (*)

  1. Cannot inherit value from parent scopes.

Additional information

I found in xdebug that the function getFieldPath on the module-config is called with wrong parameters.

Function getFieldPath is declared as below Model/Config.php#L294

https://github.com/magento/magento2/blob/5f3b86ab4bd3e3b94e65429fed33f748d29c1bbe/app/code/Magento/Config/Model/Config.php#L285-L294

In function _processGroup the parameter $extraOldGroups is passed instead of $oldConfig.
Config/Model/Config.php#L456

https://github.com/magento/magento2/blob/5f3b86ab4bd3e3b94e65429fed33f748d29c1bbe/app/code/Magento/Config/Model/Config.php#L456

As this two parameter are passed by reference $extraOldGroups overwritte the $oldConfig consequently the checkbox status won't validate and the value is not deleted.

https://github.com/magento/magento2/blob/5f3b86ab4bd3e3b94e65429fed33f748d29c1bbe/app/code/Magento/Config/Model/Config.php#L460-L471

I've noticed inheritance problems between scopes when trying to use multiples sections in system.xml.

ready for confirmation Reported on 2.2.x

Most helpful comment

The bug is revealed by a third-party extension, yes. But it is still caused by a Magento Core technical issue.

I can replicate it by setting a field's config_path property to a different section. Simplified example:

<section id="foo">
    <group id="b">
        <field id="c" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Foo</label>
            <config_path>bar/b/c</config_path>
        </field>
    </group>
</section>

Fixing the argument order as detected by @brian-ebizmarts solves the issue.

@shikhamis11 @engcom-Bravo This needs to be reopened.

All 15 comments

Thanks for opening this issue!

Hi @brian-ebizmarts. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

@brian-ebizmarts do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Thanks for opening this issue!

@magento give me 2.4-develop instance

Hi @gauravagarwal1001. Thank you for your request. I'm working on Magento 2.4-develop instance for you

Hi @gauravagarwal1001, here is your Magento instance.
Admin access: https://i-26732-2-4-develop.instances.magento-community.engineering/admin_e554
Login: 5c1a94c8 Password: 01f7f3143cb0
Instance will be terminated in up to 3 hours.

Hi @shikhamis11. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hi @brian-ebizmarts
I checked this issue is not reproducible at 2.4-develop instance .. let me know if it requires any additional steps to reproduce this issue .. also please share video or screenshots if you are able to reproduce this issue .

Hi @shikhamis11, here is a video in Magento EE 2.3.2 instance:
https://drive.google.com/file/d/1UUa1HlARvJ83NOH1FgLY_AlcsMZ3XCvG/view?usp=sharing

Let me know if you need anything else.

Hi @shikhamis11, this issue is reproducible with multiples sections in the System.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Magento/Config/etc/system_file.xsd">
    <system>
        <tab id="pos" translate="label" sortOrder="550">
            <label>POS by Ebizmarts</label>
        </tab>
        <section id="pos_general" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
           .....
        </section>
        <section id="pos_payment" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Payment Methods</label>
            <tab>pos</tab>
            <resource>Ebizmarts_Pos::pos_config</resource>
            .....
        </section>
        <section id="pos_shipping" translate="label" type="text" sortOrder="300" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Shipping methods</label>
            <tab>pos</tab>
            <resource>Ebizmarts_Pos::pos_config</resource>
            .....
        </section>
        <section id="pos_cron" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Cron</label>
            <tab>pos</tab>
            <resource>Ebizmarts_Pos::cron_pos</resource>
            .....
        </section>
        <section id="pos_backup" translate="label" type="text" sortOrder="500" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Backups</label>
            <tab>pos</tab>
            <resource>Ebizmarts_Pos::backup_pos</resource>
            .....
        </section>
    </system>
</config>

I've to mention that only in the first section id(pos_general) the checkbox "Use website" works as expected and delete the entry in core_config_data table. In the other sections pos_payment, pos_shipping, pos_cron, pos_backup is not working.

Replacing this line:
https://github.com/magento/magento2/blob/5f3b86ab4bd3e3b94e65429fed33f748d29c1bbe/app/code/Magento/Config/Model/Config.php#L456

To pass the parameters as in the function declaration it works correctly:
$path = $this->getFieldPath($field, $fieldId, $oldConfig, $extraOldGroups);

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @brian-ebizmarts

Thank you for your report.

It looks like you have third-party extensions installed on your Magento instance.
Unfortunately, we have to close this issue. The GitHub issue tracker is intended for Magento Core technical issues only.
Please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue.

Thank you

The bug is revealed by a third-party extension, yes. But it is still caused by a Magento Core technical issue.

I can replicate it by setting a field's config_path property to a different section. Simplified example:

<section id="foo">
    <group id="b">
        <field id="c" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Foo</label>
            <config_path>bar/b/c</config_path>
        </field>
    </group>
</section>

Fixing the argument order as detected by @brian-ebizmarts solves the issue.

@shikhamis11 @engcom-Bravo This needs to be reopened.

Based on feedback it seems issue should be reopened and re-verified one more time on the 2.4-develop

Hi @engcom-Alfa. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Was this page helpful?
0 / 5 - 0 ratings