Apply changes made live on Wikimedia cluster related to preprocessor caching to subve...
[lhc/web/wiklou.git] / includes / SearchOracle.php
index 92baa46..b48d5e6 100644 (file)
 # http://www.gnu.org/copyleft/gpl.html
 
 /**
- * Search engine hook base class for Oracle (ConText).
- * @addtogroup Search
+ * @file
+ * @ingroup Search
  */
 
+/**
+ * Search engine hook base class for Oracle (ConText).
+ * @ingroup Search
+ */
 class SearchOracle extends SearchEngine {
        function __construct($db) {
                $this->db = $db;
@@ -71,9 +75,12 @@ class SearchOracle extends SearchEngine {
         * @private
         */
        function queryNamespaces() {
-               $namespaces = implode(',', $this->namespaces);
-               if ($namespaces == '') {
+               if( is_null($this->namespaces) )
+                       return '';
+               if ( !count( $this->namespaces ) ) {
                        $namespaces = '0';
+               } else {
+                       $namespaces = $this->db->makeList( $this->namespaces );
                }
                return 'AND page_namespace IN (' . $namespaces . ')';
        }
@@ -138,7 +145,10 @@ class SearchOracle extends SearchEngine {
                        'WHERE page_id=si_page AND ' . $match;
        }
 
-       /** @todo document */
+       /** 
+        * Parse a user input search string, and return an SQL fragment to be used 
+        * as part of a WHERE clause
+        */
        function parseQuery($filteredText, $fulltext) {
                global $wgContLang;
                $lc = SearchEngine::legalSearchChars();
@@ -164,9 +174,9 @@ class SearchOracle extends SearchEngine {
                        }
                }
 
-               $searchon = $this->db->strencode(join(',', $q));
+               $searchon = $this->db->addQuotes(join(',', $q));
                $field = $this->getIndexField($fulltext);
-               return " CONTAINS($field, '$searchon', 1) > 0 ";
+               return " CONTAINS($field, $searchon, 1) > 0 ";
        }
 
        /**
@@ -186,6 +196,8 @@ class SearchOracle extends SearchEngine {
                                'si_title' => $title,
                                'si_text' => $text
                        ), 'SearchOracle::update' );
+               $dbw->query("CALL ctx_ddl.sync_index('si_text_idx')");
+               $dbw->query("CALL ctx_ddl.sync_index('si_title_idx')");
        }
 
        /**
@@ -195,7 +207,7 @@ class SearchOracle extends SearchEngine {
         * @param int $id
         * @param string $title
         */
-    function updateTitle( $id, $title ) {
+       function updateTitle($id, $title) {
                $dbw = wfGetDB(DB_MASTER);
 
                $dbw->update('searchindex',
@@ -206,6 +218,9 @@ class SearchOracle extends SearchEngine {
        }
 }
 
+/**
+ * @ingroup Search
+ */
 class OracleSearchResultSet extends SearchResultSet {
        function __construct($resultSet, $terms) {
                $this->mResultSet = $resultSet;
@@ -222,12 +237,8 @@ class OracleSearchResultSet extends SearchResultSet {
 
        function next() {
                $row = $this->mResultSet->fetchObject();
-               if( $row === false) {
+               if ($row === false)
                        return false;
-               } else {
-                       return new SearchResult($row);
-               }
+               return new SearchResult($row);
        }
 }
-
-?>