* (bug 13265) Media handler is missing 'image/x-bmp'
* (bug 13407) MediaWiki:Powersearch is used in two places
* (bug 13403) Fix cache invalidation of history pages when old revisions change
+* (bug 11563) Deprecated SearchMySQL4 class; merged code to SearchMySQL
=== API changes in 1.13 ===
if( $wgSearchType ) {
$class = $wgSearchType;
} elseif( $wgDBtype == 'mysql' ) {
- $class = 'SearchMySQL4';
+ $class = 'SearchMySQL';
} else if ( $wgDBtype == 'postgres' ) {
$class = 'SearchPostgres';
} else if ( $wgDBtype == 'oracle' ) {
# http://www.gnu.org/copyleft/gpl.html
/**
- * Search engine hook base class for MySQL.
- * Specific bits for MySQL 3 and 4 variants are in child classes.
+ * Search engine hook for MySQL 4+
* @addtogroup Search
*/
class SearchMySQL extends SearchEngine {
+ var $strictMatching = true;
+
+ /** @todo document */
+ function __construct( $db ) {
+ $this->db = $db;
+ }
+
+ /** @todo document */
+ function parseQuery( $filteredText, $fulltext ) {
+ global $wgContLang;
+ $lc = SearchEngine::legalSearchChars(); // Minus format chars
+ $searchon = '';
+ $this->searchTerms = array();
+
+ # FIXME: This doesn't handle parenthetical expressions.
+ $m = array();
+ if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
+ $filteredText, $m, PREG_SET_ORDER ) ) {
+ foreach( $m as $terms ) {
+ if( $searchon !== '' ) $searchon .= ' ';
+ if( $this->strictMatching && ($terms[1] == '') ) {
+ $terms[1] = '+';
+ }
+ $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
+ if( !empty( $terms[3] ) ) {
+ // Match individual terms in result highlighting...
+ $regexp = preg_quote( $terms[3], '/' );
+ if( $terms[4] ) $regexp .= "[0-9A-Za-z_]+";
+ } else {
+ // Match the quoted term in result highlighting...
+ $regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' );
+ }
+ $this->searchTerms[] = "\b$regexp\b";
+ }
+ wfDebug( "Would search with '$searchon'\n" );
+ wfDebug( 'Match with /\b' . implode( '\b|\b', $this->searchTerms ) . "\b/\n" );
+ } else {
+ wfDebug( "Can't understand search query '{$filteredText}'\n" );
+ }
+
+ $searchon = $this->db->strencode( $searchon );
+ $field = $this->getIndexField( $fulltext );
+ return " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) ";
+ }
+
+ public static function legalSearchChars() {
+ return "\"*" . parent::legalSearchChars();
+ }
+
/**
* Perform a full text search query and return a result set.
*
'si_page' => $id,
'si_title' => $title,
'si_text' => $text
- ), 'SearchMySQL4::update' );
+ ), __METHOD__ );
}
/**
$dbw->update( 'searchindex',
array( 'si_title' => $title ),
array( 'si_page' => $id ),
- 'SearchMySQL4::updateTitle',
+ __METHOD__,
array( $dbw->lowPriorityOption() ) );
}
}
/**
* Search engine hook for MySQL 4+
+ * This class retained for backwards compatibility...
+ * The meat's been moved to SearchMySQL, since the 3.x variety is gone.
* @addtogroup Search
+ * @deprecated
*/
class SearchMySQL4 extends SearchMySQL {
- var $strictMatching = true;
-
- /** @todo document */
- function SearchMySQL4( $db ) {
- $this->db = $db;
- }
-
- /** @todo document */
- function parseQuery( $filteredText, $fulltext ) {
- global $wgContLang;
- $lc = SearchEngine::legalSearchChars(); // Minus format chars
- $searchon = '';
- $this->searchTerms = array();
-
- # FIXME: This doesn't handle parenthetical expressions.
- $m = array();
- if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
- $filteredText, $m, PREG_SET_ORDER ) ) {
- foreach( $m as $terms ) {
- if( $searchon !== '' ) $searchon .= ' ';
- if( $this->strictMatching && ($terms[1] == '') ) {
- $terms[1] = '+';
- }
- $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
- if( !empty( $terms[3] ) ) {
- // Match individual terms in result highlighting...
- $regexp = preg_quote( $terms[3], '/' );
- if( $terms[4] ) $regexp .= "[0-9A-Za-z_]+";
- } else {
- // Match the quoted term in result highlighting...
- $regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' );
- }
- $this->searchTerms[] = "\b$regexp\b";
- }
- wfDebug( "Would search with '$searchon'\n" );
- wfDebug( 'Match with /\b' . implode( '\b|\b', $this->searchTerms ) . "\b/\n" );
- } else {
- wfDebug( "Can't understand search query '{$filteredText}'\n" );
- }
-
- $searchon = $this->db->strencode( $searchon );
- $field = $this->getIndexField( $fulltext );
- return " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) ";
- }
-
- public static function legalSearchChars() {
- return "\"*" . parent::legalSearchChars();
- }
+ /* whee */
}
-
class SearchTsearch2 extends SearchEngine {
var $strictMatching = false;
- function SearchTsearch2( &$db ) {
- $this->db =& $db;
+ function __construct( $db ) {
+ $this->db = $db;
$this->mRanking = true;
}
wfDebug( "Can't understand search query '{$this->filteredText}'\n" );
}
- $searchon = preg_replace('/(\s+)/','&',$searchon);
+ $searchon = preg_replace( '/(\s+)/', '&', $searchon );
$searchon = $this->db->strencode( $searchon );
return $searchon;
}
- function queryRanking($filteredTerm, $fulltext) {
+ function queryRanking( $filteredTerm, $fulltext ) {
$field = $this->getIndexField( $fulltext );
- $searchon = $this->parseQuery($filteredTerm,$fulltext);
+ $searchon = $this->parseQuery( $filteredTerm, $fulltext );
if ($this->mRanking)
return " ORDER BY rank($field,to_tsquery('$searchon')) DESC";
else
}
function update( $id, $title, $text ) {
- $dbw = wfGetDB(DB_MASTER);
+ $dbw = wfGetDB( DB_MASTER );
$searchindex = $dbw->tableName( 'searchindex' );
$sql = "DELETE FROM $searchindex WHERE si_page={$id}";
- $dbw->query($sql,"SearchTsearch2:update");
+ $dbw->query( $sql, __METHOD__ );
$sql = "INSERT INTO $searchindex (si_page,si_title,si_text) ".
" VALUES ( $id, to_tsvector('".
$dbw->strencode($title).
"'),to_tsvector('".
$dbw->strencode( $text)."')) ";
- $dbw->query($sql,"SearchTsearch2:update");
+ $dbw->query($sql, __METHOD__ );
}
function updateTitle($id,$title) {
$dbw->strencode( $title ) .
"') WHERE si_page={$id}";
- $dbw->query( $sql, "SearchMySQL4::updateTitle" );
+ $dbw->query( $sql, __METHOD__ );
}
}