Skip to content

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

@matthew-muscat

Description

@matthew-muscat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/AppFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions