Changing URLs of mediawiki.org in scripts to the SSL-based website
[lhc/web/wiklou.git] / includes / search / SearchPostgres.php
index 148a657..9dc1e77 100644 (file)
@@ -3,7 +3,7 @@
  * PostgreSQL search engine
  *
  * Copyright © 2006-2007 Greg Sabino Mullane <greg@turnstep.com>
- * http://www.mediawiki.org/
+ * https://www.mediawiki.org/
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * Search engine hook base class for Postgres
  * @ingroup Search
  */
-class SearchPostgres extends SearchEngine {
-
-       /**
-        * @var DatabasePostgres
-        */
-       protected $db;
-       /**
-        * Creates an instance of this class
-        * @param $db DatabaseSqlite: database object
-        */
-       function __construct( $db ) {
-               parent::__construct( $db );
-       }
-
+class SearchPostgres extends SearchDatabase {
        /**
         * Perform a full text search query via tsearch2 and return a result set.
         * Currently searches a page's current title (page.page_title) and
@@ -64,7 +51,7 @@ class SearchPostgres extends SearchEngine {
 
        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 ) {
@@ -97,8 +84,8 @@ class SearchPostgres extends SearchEngine {
 
                $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 .= ' & !';
                                }
@@ -169,8 +156,8 @@ class SearchPostgres extends SearchEngine {
                }
                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];
                                }
                        }
@@ -182,11 +169,12 @@ class SearchPostgres extends SearchEngine {
                }
 
                ## Redirects
-               if ( !$this->showRedirects )
+               if ( !$this->showRedirects ) {
                        $query .= ' AND page_is_redirect = 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 {
@@ -244,7 +232,7 @@ class PostgresSearchResultSet extends SqlSearchResultSet {
 
        function next() {
                $row = $this->mResultSet->fetchObject();
-               if( $row === false ) {
+               if ( $row === false ) {
                        return false;
                } else {
                        return new PostgresSearchResult( $row );