How can I get MediaWiki to ignore page views from a Google Search Appliance?

两盒软妹~` 提交于 2020-01-14 20:41:52

问题


The page view counter on each MediaWiki page seems like a great way to identify popular pages which are worth putting more effort into keeping up-to-date and useful, but I've hit a problem.

We use a Google Search Appliance to index our MediaWiki installation. The problem I have is that the GSA increments the page view counter each time it crawls the page. This completely dominates the statistics, swamping the views made by real users.

I know how to reset the page counters to start again. But is there a way to configure MediaWiki to ignore page requests from the GSA for the purposes of counting page views?


回答1:


this can be done by adding a condition in Article.php:

includes/Article.php:2861:function viewUpdates():

if( !$wgDisableCounters && !$wgUser->isAllowed('bot') && $this->getID() ) {

add:

&& strpos($_SERVER['HTTP_USER_AGENT'], 'gsa-crawler') === false

where gsa-crawler is part of the default gsa UA...

another way is to setup Forms Authentication in GSA, and have it login to wikimedia as a user in the bot group..




回答2:


We added this snippet to LocalSettings.php, with great success:

if (strpos($_SERVER['HTTP_USER_AGENT'], 'gsa-crawler') !== FALSE) {
  $wgDisableCounters = TRUE;
}

Thanks!



来源:https://stackoverflow.com/questions/2096170/how-can-i-get-mediawiki-to-ignore-page-views-from-a-google-search-appliance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!