[Mediawiki-l] Dirty hack for phrase search

Jack Eapen C jackec at suntecgroup.com
Mon Jan 14 07:29:10 UTC 2008

Hi all,

I'm not sure whether there is a provision to search for an exact phrase
exists in Mediawiki's default search or not.
So I made this dirty hack. Since my wiki is not public, not afraid of
any SQL injection attacks or so. 
So if u feel u r not vulnerable, try this:

Edit includes/SearchEngine.php 

	function filter( $text ) {
		$lc = $this->legalSearchChars();
		//return trim( preg_replace( "/[^{$lc}]/", " ", $text )
);  //dirty hack by Jack-to get exact phrase search
		return trim($text);
I commented out the  return trim( preg_replace( "/[^{$lc}]/", " ", $text
) ); I don't know what impact this will make.. I don't know the pattern
of preg_replace. If there's a way to excluse double quotes from that
function, tell me that. 

So now u can search for "black holes" , with quotes, and mediawiki will
find results only where the exact phrase appear and not "black tea and
key hole"
Jack Eapen C
SunTec Knowledge Centre
"Management is doing things right; leadership is doing the right things"

This electronic mail (including any attachment thereto) may be confidential and privileged and is intended only for the individual or entity named above. Any unauthorized use, printing, copying, disclosure or dissemination of this communication may be subject to legal restriction or sanction. Accordingly, if you are not the intended recipient, please notify the sender by replying to this email immediately and delete this email (and any attachment thereto) from your computer system...Thank You

More information about the MediaWiki-l mailing list