Skip to content

Commit 59af647

Browse files
committed
MAGETWO-86143: Disable statistic collecting for Reports module
1 parent 436a064 commit 59af647

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class Visitor extends \Magento\Framework\Model\AbstractModel
4040
protected $httpHeader;
4141

4242
/**
43-
* Skip logging during request. Do not use this property directly, but use self::isSkipRequestLogging instead
44-
*
4543
* @var bool
4644
*/
4745
protected $skipRequestLogging = false;
@@ -145,19 +143,6 @@ public function setSkipRequestLogging($skipRequestLogging)
145143
return $this;
146144
}
147145

148-
/**
149-
* Check if we can log request fot event. Additionally prevent logging for safe methods (e.g. GET request)
150-
*
151-
* @return bool
152-
*/
153-
private function isSkipRequestLogging()
154-
{
155-
if ($this->requestSafety->isSafeMethod()) {
156-
return true;
157-
}
158-
return $this->skipRequestLogging;
159-
}
160-
161146
/**
162147
* Initialization visitor by request
163148
*
@@ -168,7 +153,7 @@ private function isSkipRequestLogging()
168153
*/
169154
public function initByRequest($observer)
170155
{
171-
if ($this->isSkipRequestLogging() || $this->isModuleIgnored($observer)) {
156+
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
172157
return $this;
173158
}
174159

@@ -181,6 +166,10 @@ public function initByRequest($observer)
181166

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

169+
// prevent saving Visitor for safe methods, e.g. GET request
170+
if ($this->requestSafety->isSafeMethod()) {
171+
return $this;
172+
}
184173
if (!$this->getId()) {
185174
$this->setSessionId($this->session->getSessionId());
186175
$this->save();
@@ -200,7 +189,8 @@ public function initByRequest($observer)
200189
*/
201190
public function saveByRequest($observer)
202191
{
203-
if ($this->isSkipRequestLogging() || $this->isModuleIgnored($observer)) {
192+
// prevent saving Visitor for safe methods, e.g. GET request
193+
if ($this->skipRequestLogging || $this->requestSafety->isSafeMethod() || $this->isModuleIgnored($observer)) {
204194
return $this;
205195
}
206196

0 commit comments

Comments
 (0)