How can I make MediaWiki ignore pageviews from the search appliance?

The pageview counter on each page of MediaWiki seems like a great way to identify the popular pages that are worth the effort to be relevant and useful, but I ran into a problem.

We use the Google Search Appliance to index our MediaWiki installation. The problem is that the GSA increases the pageview counter every time it views the page. This completely dominates the statistics, absorbing the views of real users.

I know how to reset page counts to start over. But is there a way to configure MediaWiki to ignore page requests from the GSA to count page views?

+3
source share
2 answers

this can be done by adding a condition to 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-finder is part of gsa UA by default ...

Another way is to set up forms authentication in the GSA and log into wikimedia as a user in the bot group.

+3
source

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

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

Thank!

+3
source

Source: https://habr.com/ru/post/1729117/


All Articles