Skip to content

Commit 7d7084b

Browse files
author
Joan He
committed
Merge remote-tracking branch 'trigger/MC-15378' into pr
2 parents bb7d459 + 4461e54 commit 7d7084b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

app/code/Magento/Customer/Model/Visitor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
* @package Magento\Customer\Model
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1718
*/
1819
class Visitor extends \Magento\Framework\Model\AbstractModel
1920
{
@@ -168,10 +169,6 @@ public function initByRequest($observer)
168169

169170
$this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
170171

171-
// prevent saving Visitor for safe methods, e.g. GET request
172-
if ($this->requestSafety->isSafeMethod()) {
173-
return $this;
174-
}
175172
if (!$this->getId()) {
176173
$this->setSessionId($this->session->getSessionId());
177174
$this->save();

dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,21 @@ public function loginPostRedirectDataProvider()
751751
];
752752
}
753753

754+
/**
755+
* @magentoDataFixture Magento/Customer/_files/customer.php
756+
* @magentoDataFixture Magento/Customer/_files/customer_address.php
757+
* @magentoAppArea frontend
758+
*/
759+
public function testCheckVisitorModel()
760+
{
761+
/** @var \Magento\Customer\Model\Visitor $visitor */
762+
$visitor = $this->_objectManager->get(\Magento\Customer\Model\Visitor::class);
763+
$this->login(1);
764+
$this->assertNull($visitor->getId());
765+
$this->dispatch('customer/account/index');
766+
$this->assertNotNull($visitor->getId());
767+
}
768+
754769
/**
755770
* @param string $email
756771
* @return void

0 commit comments

Comments
 (0)