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 for Issue #7227: "x_forwarded_for" value is always empty in Order object #21787

Merged
merged 3 commits into from
Apr 26, 2019
Merged

Fix for Issue #7227: "x_forwarded_for" value is always empty in Order object #21787

merged 3 commits into from
Apr 26, 2019

Conversation

cmuench
Copy link
Contributor

@cmuench cmuench commented Mar 16, 2019

Description

I added the header logic of the quote session to the Quote Management service. This will fill the currently empty x_forwarded_for column in the sales_order table.

Fixed Issues

  1. "x_forwarded_for" value is always empty in Order object. #7227: "x_forwarded_for" value is always empty in Order object.

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
  • All automated tests passed successfully

@magento-engcom-team
Copy link
Contributor

Hi @cmuench. Thank you for your contribution
Here is 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-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

app/code/Magento/Quote/Model/QuoteManagement.php Outdated Show resolved Hide resolved
if ($remoteAddress) {
$quote->setRemoteIp($remoteAddress);
$xForwardIp = $this->request->getServer('HTTP_X_FORWARDED_FOR');
$quote->setXForwardedFor($xForwardIp);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should check for emptiness here? Variable name looks strange, why not $forwardedForIp or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code is the same as in \Magento\Checkout\Model\remoteAddress::getQuote.
I checked the docblock of \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::getRemoteAddress. IMHO the @return type is wrong. It should be "@return int|bool|string".
What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also possible to inline the code. The variable is not really needed.

$this->requestMock
->expects($this->once())
->method('getServer')
->willReturn($xForwarderForHeader);
Copy link
Contributor

Choose a reason for hiding this comment

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

We must assert data was actually set to quote, please consider making a separate tiny test method. Don't use unneeded execution flow checks like $this->once, we prefer to verify code behavior rather than execution flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will remove that, but in the same test case is $this->once already used several times for similar checks.
I already tried to create an own test method, but it's hard because I have to copy&paste a lot of stuff.

@cmuench cmuench requested a review from orlangur March 16, 2019 15:40
@magento-engcom-team
Copy link
Contributor

Hi @orlangur, thank you for the review.
ENGCOM-4712 has been created to process this Pull Request

@VasylShvorak
Copy link
Contributor

VasylShvorak commented Apr 18, 2019

✔️ QA passed

@magento-engcom-team magento-engcom-team merged commit c4e4cbd into magento:2.3-develop Apr 26, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 26, 2019

Hi @cmuench, 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.

magento-engcom-team pushed a commit that referenced this pull request Apr 26, 2019
@magento-engcom-team magento-engcom-team added this to the Release: 2.3.2 milestone Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants