Extension:Log Searches

From MediaWiki.org

Jump to: navigation, search
This extension requires patches to core MediaWiki code . Extensions implemented using patches may be disabled by or interfere with upgrades and security patches. If a suitable alternative without a patch is available, we recommend you use that extension instead.


       

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Log Searches

Release status: experimental

Implementation  User interface
Description logs searches into file
Author(s)  Flominator
MediaWiki  tested with 1.67
License No license specified
Download no link

check usage (experimental)

At the moment, this one is just a dirty hack in order to log your search results into a comma separated file, which can be analyzed manually. This originally was a response to Project:Extension_requests#Search_statistics and is far from complete. In order to turn this into a "real" extension a new hook would have to added into Special:Search. --Flominator 09:21, 25 October 2007 (UTC)

Update: Although the hooks are now included, Extension:SearchLog might be a better solution. --Flominator 09:49, 27 June 2009 (UTC)

[edit] Installation

Place this code in /extensions/LogSearches.php ...

<?php
 
function log_goResult($term)
{
	logSearch("Artikelsuche;$term");
}
 
function log_showResults($term)
{
	logSearch("Volltextsuche;$term");
 
}
function logSearch($line)
{
	$f = fopen("./extensions/searchlog.csv", "a");
	fputs($f, $_SERVER['REMOTE_ADDR'] .';'. strftime("%Y-%m-%d;%H:%M").";$line;$time\n");
	fclose($f);
}
?>

... and this one in /LocalSettings.php ...

require_once("$IP/extensions/LogSearches.php")

... and modify /includes/SpecialSearch.php:

line 83:

function goResult( $term ) {
 log_goResult($term);
global $wgOut;

line 129

function showResults( $term ) {
 log_showResults($term);
$fname = 'SpecialSearch::showResults';

[edit] Promised solution

Looks like MW 1.13alpha has the solution for the patching above:

'SpecialSearchResults': called before search result display when there are matches
$term: string of search term
$titleMatches: empty or SearchResultSet object
$textMatches: empty or SearchResultSet object

Then release is scheduled around July 2008 ...