Skip to content

Commit c0d136a

Browse files
Improved handling of ignore_user_agents (OpenMage#3238)
Co-authored-by: Fabrizio Balliano <[email protected]>
1 parent 0e8319c commit c0d136a

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

app/code/core/Mage/Log/Model/Visitor.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,22 @@ public function __construct(array $data = [])
101101
protected function _construct()
102102
{
103103
$this->_init('log/visitor');
104-
$userAgent = $this->_httpHelper->getHttpUserAgent();
104+
if ($this->_logCondition->isLogDisabled()) {
105+
$this->_skipRequestLogging = true;
106+
return;
107+
}
108+
105109
$ignoreAgents = $this->_config->getNode('global/ignore_user_agents');
106110
if ($ignoreAgents) {
107111
$ignoreAgents = $ignoreAgents->asArray();
108-
if (in_array($userAgent, $ignoreAgents)) {
109-
$this->_skipRequestLogging = true;
112+
$userAgent = $this->_httpHelper->getHttpUserAgent();
113+
foreach ($ignoreAgents as $ignoreAgent) {
114+
if (stripos($userAgent, $ignoreAgent) !== false) {
115+
$this->_skipRequestLogging = true;
116+
break;
117+
}
110118
}
111119
}
112-
if ($this->_logCondition->isLogDisabled()) {
113-
$this->_skipRequestLogging = true;
114-
}
115120
}
116121

117122
/**

app/code/core/Mage/Log/etc/config.xml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,28 @@
2929
</entities>
3030
</ignoredModules>
3131
<ignore_user_agents>
32-
<google1>Googlebot/1.0 ([email protected] http://googlebot.com/)</google1>
33-
<google2>Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</google2>
34-
<google3>Googlebot/2.1 (+http://www.googlebot.com/bot.html)</google3>
32+
<adsbot>AdsBot</adsbot>
33+
<alphabot>AlphaBot</alphabot>
34+
<amazonbot>Amazonbot</amazonbot>
35+
<bingbot>bingbot</bingbot>
36+
<blexbot>BLEXBot</blexbot>
37+
<dotbot>DotBot</dotbot>
38+
<facebookexternalhit>facebookexternalhit</facebookexternalhit>
39+
<google>Googlebot</google>
40+
<google-site-verification>Google-Site-Verification</google-site-verification>
41+
<hrefsbot>AhrefsBot</hrefsbot>
42+
<istellabot>istellabot</istellabot>
43+
<mauibot>MauiBot</mauibot>
44+
<mj12bot>MJ12bot</mj12bot>
45+
<mod_pagespeed>mod_pagespeed</mod_pagespeed>
46+
<opensiteexplorer>spbot</opensiteexplorer>
47+
<pinterestbot>Pinterestbot</pinterestbot>
48+
<semrushbot>SemrushBot</semrushbot>
49+
<seotester>SEOTesterBot</seotester>
50+
<yandexbot>YandexBot</yandexbot>
51+
<yandeximage>YandexImages</yandeximage>
52+
<yandexmobilebot>YandexMobileBot</yandexmobilebot>
53+
<zoominfobot>ZoominfoBot</zoominfobot>
3554
</ignore_user_agents>
3655
<helpers>
3756
<log>

0 commit comments

Comments
 (0)