From c0d136a15bed3972997da017d0badf11dac89db6 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 13 May 2023 14:06:35 +0200 Subject: [PATCH] Improved handling of ignore_user_agents (#3238) Co-authored-by: Fabrizio Balliano --- app/code/core/Mage/Log/Model/Visitor.php | 17 ++++++++++------ app/code/core/Mage/Log/etc/config.xml | 25 +++++++++++++++++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/core/Mage/Log/Model/Visitor.php index 96b8e29d344..751a504d5f7 100644 --- a/app/code/core/Mage/Log/Model/Visitor.php +++ b/app/code/core/Mage/Log/Model/Visitor.php @@ -101,17 +101,22 @@ public function __construct(array $data = []) protected function _construct() { $this->_init('log/visitor'); - $userAgent = $this->_httpHelper->getHttpUserAgent(); + if ($this->_logCondition->isLogDisabled()) { + $this->_skipRequestLogging = true; + return; + } + $ignoreAgents = $this->_config->getNode('global/ignore_user_agents'); if ($ignoreAgents) { $ignoreAgents = $ignoreAgents->asArray(); - if (in_array($userAgent, $ignoreAgents)) { - $this->_skipRequestLogging = true; + $userAgent = $this->_httpHelper->getHttpUserAgent(); + foreach ($ignoreAgents as $ignoreAgent) { + if (stripos($userAgent, $ignoreAgent) !== false) { + $this->_skipRequestLogging = true; + break; + } } } - if ($this->_logCondition->isLogDisabled()) { - $this->_skipRequestLogging = true; - } } /** diff --git a/app/code/core/Mage/Log/etc/config.xml b/app/code/core/Mage/Log/etc/config.xml index 41e8f048295..f7119dd1259 100644 --- a/app/code/core/Mage/Log/etc/config.xml +++ b/app/code/core/Mage/Log/etc/config.xml @@ -29,9 +29,28 @@ - Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/) - Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) - Googlebot/2.1 (+http://www.googlebot.com/bot.html) + AdsBot + AlphaBot + Amazonbot + bingbot + BLEXBot + DotBot + facebookexternalhit + Googlebot + Google-Site-Verification + AhrefsBot + istellabot + MauiBot + MJ12bot + mod_pagespeed + spbot + Pinterestbot + SemrushBot + SEOTesterBot + YandexBot + YandexImages + YandexMobileBot + ZoominfoBot