r21646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21645‎ | r21646 | r21647 >
Date:03:45, 27 April 2007
Author:greg
Status:old
Tags:
Comment:
Defer populating searchTerms until later on - allows for better highlighting.
Modified paths:
  • /trunk/phase3/includes/SearchPostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SearchPostgres.php
@@ -63,8 +63,6 @@
6464 ## Treat colons as word separators:
6565 $term = preg_replace('/:/', ' ', $term);
6666
67 - $this->searchTerms = array();
68 - $m = array();
6967 $searchstring = '';
7068 if( preg_match_all('/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) {
7169 foreach( $m as $terms ) {
@@ -82,9 +80,6 @@
8381 }
8482 else {
8583 $searchstring .= " & $terms[2]";
86 - $safeterm = preg_replace('/\W+/', '', $terms[2]);
87 - if (strlen($safeterm))
88 - $this->searchTerms[$safeterm] = $safeterm;
8984 }
9085 }
9186 }
@@ -138,6 +133,13 @@
139134 "AND r.rev_text_id = c.old_id AND 1=0";
140135 }
141136 else {
 137+ $m = array();
 138+ if( preg_match_all("/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) {
 139+ foreach( $m as $terms ) {
 140+ $this->searchTerms[$terms[1]] = $terms[1];
 141+ }
 142+ }
 143+
142144 $query = "SELECT page_id, page_namespace, page_title, ".
143145 "rank($fulltext, to_tsquery('default',$searchstring),5) AS score ".
144146 "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .