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

Fix "area code is not set" in all commands that depend on Payment/Helper/Data #33726

Merged
merged 10 commits into from
Oct 28, 2021

Conversation

marvinhinz
Copy link
Contributor

@marvinhinz marvinhinz commented Aug 9, 2021

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)

  1. Fixes Magento 2.4.2 composer upgrade broke after 2.4.3 released #33760

Manual testing scenarios (*)

  1. Create a custom Command, inject Magento\Sales\Model\Service\InvoiceService or the mentioned helper directly, or some class that depends on it
  2. Dont specify an area, because its not always needed, or you dont actually intend to use the layout
  3. 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)

Resolved issues:

  1. resolves [Issue] Fix "area code is not set" in all commands that depend on Payment/Helper/Data #33908: Fix "area code is not set" in all commands that depend on Payment/Helper/Data

@m2-assistant
Copy link

m2-assistant bot commented Aug 9, 2021

Hi @marvinhinz. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@marvinhinz
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@@ -183,7 +176,7 @@ public function getMethodFormBlock(MethodInterface $method, LayoutInterface $lay
*/
public function getInfoBlock(InfoInterface $info, LayoutInterface $layout = null)
{
$layout = $layout ?: $this->_layout;
$layout = $layout ?: $layoutFactory->create();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $layoutFactory variable won't exist here, you'll need to store it in a private member in the constructor to be able to use it, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I'm too slow 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized after clicking on create pr :D

@m2-community-project m2-community-project bot added this to Review in Progress in Pull Requests Dashboard Aug 9, 2021
@hostep hostep removed their assignment Aug 9, 2021
@m2-community-project m2-community-project bot moved this from Review in Progress to Pending Review in Pull Requests Dashboard Aug 9, 2021
i dont know how to squash commits :(
@marvinhinz
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@Den4ik Den4ik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marvinhinz Thanks for your contribution.
Please look at my comment

*/
protected $_layout;
protected $_layoutFactory;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't rename exist properties in @api class. It's backward incompatible.
Just add another one private property and deprecate current

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍🏼

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in Pull Requests Dashboard Aug 13, 2021
@Den4ik
Copy link
Contributor

Den4ik commented Aug 13, 2021

@magento run all tests

@engcom-Alfa
Copy link
Contributor

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@ihor-sviziev
Copy link
Contributor

@andrewbess any thoughts on why static tests are failing?

Signed-off-by: Denis Kopylov <dkopylov@magenius.team>
Signed-off-by: Denis Kopylov <dkopylov@magenius.team>
@Den4ik
Copy link
Contributor

Den4ik commented Oct 18, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@Den4ik
Copy link
Contributor

Den4ik commented Oct 18, 2021

@andrewbess any thoughts on why static tests are failing?

@ihor-sviziev I have fixed static tests and now it should be passed. I hope this PR will be proceed faster

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Integration Tests, Magento Health Index, Sample Data Tests B2B, Static Tests, Unit Tests, WebAPI Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Integration Tests, Magento Health Index, Sample Data Tests B2B, Static Tests, Unit Tests, WebAPI Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Integration Tests, Magento Health Index, Sample Data Tests B2B, Static Tests, Unit Tests, WebAPI Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

1 similar comment
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

After testing as per previous-comment, it was QA passed. But due to merge conflicts re-verified the issue again after resolving conflicts. PR is working absolutely fine. Hence forwarding the PR to Merge In Progress.

@engcom-Alfa engcom-Alfa moved this from Testing in Progress to Merge in Progress in High Priority Pull Requests Dashboard Oct 20, 2021
magento-engcom-team pushed a commit that referenced this pull request Oct 28, 2021
@magento-engcom-team magento-engcom-team merged commit f9a78dd into magento:2.4-develop Oct 28, 2021
@m2-assistant
Copy link

m2-assistant bot commented Oct 28, 2021

Hi @marvinhinz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@sidolov sidolov moved this from Merge in Progress to Recently Merged in High Priority Pull Requests Dashboard Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Component: Payment Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
9 participants