Description
This issue is automatically created based on existing pull request: #33726: Fix "area code is not set" in all commands that depend on Payment/Helper/Data
Description (*)
The Helper Magento\Payment\Helper\Data creates a new layout in the constructor. This is unneccessary and creates issues when the helper is used without specifying the area code previously (eg in commands).
Edit: Also there is no real workaround to fix this. You would need to set the area in the constructor, which in turn is called every time the command list is generated, triggering "area code is already set".
Fixed Issues (if relevant)
- Fixes magento/magento2#<issue_number>
Manual testing scenarios (*)
- Create a custom Command, inject Magento\Sales\Model\Service\InvoiceService or the mentioned helper directly, or some class that depends on it
- Dont specify an area, because its not always needed, or you dont actually intend to use the layout
- Scratch your head why it fails with error "area code is not set"
Questions or comments
I dont think a test case is neccessary for this change, because the only place $this->_layout is used, is in one single method as a fallback when no layout has been passed to getInfoBlock().
Maybe using the layoutfactory inside a constructor method should be prohibited at all, or at least trigger/log a warning message. It is troublesome to detect where the root issue comes from.
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)
- README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
- All automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status