Extension:Log Searches

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
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
Translate the Log Searches extension if it is available at translatewiki.net
Check usage and version matrix.

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)


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


function log_goResult($term)

function log_showResults($term)

function logSearch($line)
	$f = fopen("./extensions/searchlog.csv", "a");
	fputs($f, $_SERVER['REMOTE_ADDR'] .';'. strftime("%Y-%m-%d;%H:%M").";$line;$time\n");

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


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

line 83:

function goResult( $term ) {
global $wgOut;

line 129

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

Promised solution[edit]

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 ...