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

Incorrect configuration scope is occasionally returned when attempting to resolve a null scope id #16939

Closed
matthew-muscat opened this issue Jul 19, 2018 · 10 comments · Fixed by #21633
Labels
Component: Framework/App Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line help wanted Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@matthew-muscat
Copy link
Contributor

Preconditions

  1. Magento v2.2.x and Magento v2.3-develop are affected
  2. PHP v7.1

Steps to reproduce

  1. Setup a multi-store magento installation
  2. Setup a configuration value that is specific to a particular store scope
  3. Using environment emulation, emulate a store id and then attempt to retrieve the store configuration property using \Magento\Framework\App\Config\ScopeConfigInterface::getValue($configPath, 'stores')

Expected result

  • When working in a multi-store environment...
    -- The correct configuration value is retrieved based on the current store scope
    -- The correct configuration value is retrieved based on the currently emulated store environment

Actual result

  • The value returned for the configuration will be that of the default store scope, rather than the current / emulated store id.

Root cause

Proposed fix

  • The $scopeCode value that is used in the resolvedScopeCodes array should be replaced with the $resolvedScopeCode, ensuring the array is populated correctly and avoids returning an incorrect value when null is passed as the desired $scopeId
  • Additionally, the conditional checks used on the $scopeCode value can be avoided, as it does not appear to influence the result
@magento-engcom-team
Copy link
Contributor

Hi @matthew-muscat. 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-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.

@matthew-muscat do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jul 19, 2018
@engcom-backlog-nickolas engcom-backlog-nickolas added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Jul 19, 2018
@engcom-backlog-nickolas engcom-backlog-nickolas added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release help wanted Component: Framework/Config labels Jul 19, 2018
@engcom-backlog-nickolas
Copy link

engcom-backlog-nickolas commented Jul 19, 2018

Hello @matthew-muscat, thank you for your report and pull request.
We've acknowledged the issue and added to our backlog.

@matthew-muscat
Copy link
Contributor Author

@magento-engcom-team give me 2.2.5 instance

@magento-engcom-team
Copy link
Contributor

Hi @matthew-muscat. Thank you for your request. I'm working on Magento 2.2.5 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @matthew-muscat, here is your Magento instance.
Admin access: https://i-16939-2-2-5.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@matthew-muscat
Copy link
Contributor Author

@engcom-backlog-nickolas - this one's a little difficult to repeat in the test instance, as it requires a multistore setup and either environment emulation or store scope switching.

My process to verify and repeat the issue has been to use environment emulation, then using the ScopeConfigInterface::getValue to retrieve a value using just the $path and $scope params (ie: no scopeId is passed) — you'll see the incorrect value is returned, due to the ScopeCodeResolver::resolve() method not handling the null scopeId value

@engcom-backlog-nickolas

@matthew-muscat thank you for help. I've reproduced this issue locally. Thanks again for pull request.

@magento-engcom-team
Copy link
Contributor

Hi @matthew-muscat. Thank you for your report.
The issue has been fixed in #16940 by @matthew-muscat in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@Axel29
Copy link

Axel29 commented Feb 19, 2019

Hello,

This fix should have been present since 2.2.8 but I can't see it in 2.3.0.

@magento-engcom-team
Copy link
Contributor

Hi @matthew-muscat. Thank you for your report.
The issue has been fixed in #21633 by @mage2pratik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/App Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line help wanted Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
4 participants