dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Add cache versioning to InfoAction."
[lhc/web/wiklou.git]
/
includes
/
search
/
SearchPostgres.php
diff --git
a/includes/search/SearchPostgres.php
b/includes/search/SearchPostgres.php
index
56464e9
..
7f19ed1
100644
(file)
--- a/
includes/search/SearchPostgres.php
+++ b/
includes/search/SearchPostgres.php
@@
-64,7
+64,7
@@
class SearchPostgres extends SearchEngine {
function searchText( $term ) {
$q = $this->searchQuery( $term, 'textvector', 'old_text' );
function searchText( $term ) {
$q = $this->searchQuery( $term, 'textvector', 'old_text' );
- $olderror = error_reporting(
E_ERROR
);
+ $olderror = error_reporting(
E_ERROR
);
$resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
error_reporting( $olderror );
if ( !$resultSet ) {
$resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
error_reporting( $olderror );
if ( !$resultSet ) {
@@
-86,19
+86,19
@@
class SearchPostgres extends SearchEngine {
wfDebug( "parseQuery received: $term \n" );
## No backslashes allowed
wfDebug( "parseQuery received: $term \n" );
## No backslashes allowed
- $term = preg_replace(
'/\\\/', '', $term
);
+ $term = preg_replace(
'/\\\/', '', $term
);
## Collapse parens into nearby words:
## Collapse parens into nearby words:
- $term = preg_replace(
'/\s*\(\s*/', ' (', $term
);
- $term = preg_replace(
'/\s*\)\s*/', ') ', $term
);
+ $term = preg_replace(
'/\s*\(\s*/', ' (', $term
);
+ $term = preg_replace(
'/\s*\)\s*/', ') ', $term
);
## Treat colons as word separators:
## Treat colons as word separators:
- $term = preg_replace(
'/:/', ' ', $term
);
+ $term = preg_replace(
'/:/', ' ', $term
);
$searchstring = '';
$m = array();
$searchstring = '';
$m = array();
- if
( preg_match_all(
'/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) {
- foreach( $m as $terms ) {
+ if
( preg_match_all(
'/([-!]?)(\S+)\s*/', $term, $m, PREG_SET_ORDER ) ) {
+ foreach
( $m as $terms ) {
if ( strlen( $terms[1] ) ) {
$searchstring .= ' & !';
}
if ( strlen( $terms[1] ) ) {
$searchstring .= ' & !';
}
@@
-118,19
+118,19
@@
class SearchPostgres extends SearchEngine {
}
## Strip out leading junk
}
## Strip out leading junk
- $searchstring = preg_replace(
'/^[\s\&\|]+/', '', $searchstring
);
+ $searchstring = preg_replace(
'/^[\s\&\|]+/', '', $searchstring
);
## Remove any doubled-up operators
## Remove any doubled-up operators
- $searchstring = preg_replace(
'/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring
);
+ $searchstring = preg_replace(
'/([\!\&\|]) +(?:[\&\|] +)+/', "$1 ", $searchstring
);
## Remove any non-spaced operators (e.g. "Zounds!")
## Remove any non-spaced operators (e.g. "Zounds!")
- $searchstring = preg_replace(
'/([^ ])[\!\&\|]/', "$1", $searchstring
);
+ $searchstring = preg_replace(
'/([^ ])[\!\&\|]/', "$1", $searchstring
);
## Remove any trailing whitespace or operators
## Remove any trailing whitespace or operators
- $searchstring = preg_replace(
'/[\s\!\&\|]+$/', '', $searchstring
);
+ $searchstring = preg_replace(
'/[\s\!\&\|]+$/', '', $searchstring
);
## Remove unnecessary quotes around everything
## Remove unnecessary quotes around everything
- $searchstring = preg_replace(
'/^[\'"](.*)[\'"]$/', "$1", $searchstring
);
+ $searchstring = preg_replace(
'/^[\'"](.*)[\'"]$/', "$1", $searchstring
);
## Quote the whole thing
$searchstring = $this->db->addQuotes( $searchstring );
## Quote the whole thing
$searchstring = $this->db->addQuotes( $searchstring );
@@
-163,30
+163,31
@@
class SearchPostgres extends SearchEngine {
$top = $top[0];
if ( $top === "" ) { ## e.g. if only stopwords are used XXX return something better
$top = $top[0];
if ( $top === "" ) { ## e.g. if only stopwords are used XXX return something better
- $query = "SELECT page_id, page_namespace, page_title, 0 AS score ".
+ $query = "SELECT page_id, page_namespace, page_title, 0 AS score "
.
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
"AND r.rev_text_id = c.old_id AND 1=0";
}
else {
$m = array();
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
"AND r.rev_text_id = c.old_id AND 1=0";
}
else {
$m = array();
- if
( preg_match_all(
"/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) {
- foreach( $m as $terms ) {
+ if
( preg_match_all(
"/'([^']+)'/", $top, $m, PREG_SET_ORDER ) ) {
+ foreach
( $m as $terms ) {
$this->searchTerms[$terms[1]] = $terms[1];
}
}
$this->searchTerms[$terms[1]] = $terms[1];
}
}
- $query = "SELECT page_id, page_namespace, page_title, ".
- "ts_rank($fulltext, to_tsquery($searchstring), 5) AS score ".
+ $query = "SELECT page_id, page_namespace, page_title, "
.
+ "ts_rank($fulltext, to_tsquery($searchstring), 5) AS score "
.
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
"AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($searchstring)";
}
## Redirects
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
"AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($searchstring)";
}
## Redirects
- if ( !$this->showRedirects )
+ if ( !$this->showRedirects )
{
$query .= ' AND page_is_redirect = 0';
$query .= ' AND page_is_redirect = 0';
+ }
## Namespaces - defaults to 0
## Namespaces - defaults to 0
- if( !is_null( $this->namespaces ) ) { // null -> search all
+ if
( !is_null( $this->namespaces ) ) { // null -> search all
if ( count( $this->namespaces ) < 1 ) {
$query .= ' AND page_namespace = 0';
} else {
if ( count( $this->namespaces ) < 1 ) {
$query .= ' AND page_namespace = 0';
} else {
@@
-208,7
+209,7
@@
class SearchPostgres extends SearchEngine {
function update( $pageid, $title, $text ) {
## We don't want to index older revisions
function update( $pageid, $title, $text ) {
## We don't want to index older revisions
- $SQL = "UPDATE pagecontent SET textvector = NULL WHERE old_id IN ".
+ $SQL = "UPDATE pagecontent SET textvector = NULL WHERE old_id IN "
.
"(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
" ORDER BY rev_text_id DESC OFFSET 1)";
$this->db->query( $SQL );
"(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
" ORDER BY rev_text_id DESC OFFSET 1)";
$this->db->query( $SQL );
@@
-244,7
+245,7
@@
class PostgresSearchResultSet extends SqlSearchResultSet {
function next() {
$row = $this->mResultSet->fetchObject();
function next() {
$row = $this->mResultSet->fetchObject();
- if( $row === false ) {
+ if
( $row === false ) {
return false;
} else {
return new PostgresSearchResult( $row );
return false;
} else {
return new PostgresSearchResult( $row );