[Issue] AppState emulateAreaCode was not respected by file collector #29656
Labels
Component: View
Event: MageCONF CD 2020
Fixed in 2.4.x
The issue has been fixed in 2.4-develop branch
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Issue: Ready for Work
Gate 4. Acknowledged. Issue is added to backlog and ready for development
Priority: P3
May be fixed according to the position in the backlog.
Progress: done
Reported on 2.4.0
Indicates original Magento version for the Issue report.
Reproduced on 2.4.x
The issue has been reproduced on latest 2.4-develop branch
Severity: S3
Affects non-critical data or functionality and does not force users to employ a workaround.
Uh oh!
There was an error while loading. Please reload this page.
This issue is automatically created based on existing pull request: #28917: AppState emulateAreaCode was not respected by file collector
Preconditions (*)
Magento 2.4-develop
The "hack" to emulate an area code via AppState->emulateAreaCode() is not respected by the base file collector. The consequence is that *.xml file in the emulated area is not found by the file collector.
Steps to reproduce (*)
The problem occurs in an extension I have built that require to access the adminhtml area from the graphql area. There are likely other modules in the Magento 2 that suffers from the same problem. However I can not point one such module without spending a considerable amount of time searching for it.
The following snippet suffer from this bug,
\Magento\Framework\View\File\Collector\Base
with param['subDir' => 'ui_component']
.adminhtml
area.Actual Result:
As result, we have files only from
base
area.view/base/ui_component/*
Expected Result:
As result, we have files from
base
andadminhtml
areas.view/base/ui_component/*
view/adminhtml/ui_component/*
Questions or comments
I thinks someone more knowledgable should look into this issue. I have troubleshooted and my conclusions are as follows.
The base file collector is accessing the area code of the Theme with a call to getData('area').
The Theme has an override called getArea(), this method is never called by the base file collector.
This causes problems for modules that use "emulated area codes" via the
\Magento\Framework\App\State->emulateAreaCode() method.
The emulated area code is then not respected by the file collector since it access the data directly and not via the intended getArea() method in the Theme.
Contribution checklist (*)
The text was updated successfully, but these errors were encountered: