$this->queryNamespaces() . ' ' .
$this->queryLimit();
}
+
+ /**
+ * Load up the appropriate search engine class for the currently
+ * active database backend, and return a configured instance.
+ *
+ * @return SearchEngine
+ * @access private
+ */
+ function create() {
+ global $wgDBtype, $wgDBmysql4, $wgSearchType;
+ if( $wgDBtype == 'mysql' ) {
+ if( $wgDBmysql4 ) {
+ $class = 'SearchMySQL4';
+ require_once( 'SearchMySQL4.php' );
+ } else {
+ $class = 'SearchMysql3';
+ require_once( 'SearchMySQL3.php' );
+ }
+ } else if ( $wgDBtype == 'PostgreSQL' ) {
+ $class = 'SearchTsearch2';
+ require_once( 'SearchTsearch2.php' );
+ } else {
+ $class = 'SearchEngineDummy';
+ }
+ $search = new $class( wfGetDB( DB_SLAVE ) );
+ $search->setLimitOffset(0,0);
+ return $search;
+ }
+
}
}
}
-
-?>
"FROM $cur,$searchindex " .
'WHERE cur_id=si_page AND ' . $match;
}
+
+ function update( $id, $title, $text ) {
+ $dbw=& wfGetDB(DB_MASTER);
+ $dbw->replace( 'searchindex', array(array('si_page')),
+ array(
+ 'si_page' => $id,
+ 'si_title' => $dbw->strencode($title),
+ 'si_text' => $dbw->strencode( $text )
+ ), 'SearchMySQL3::update' );
+ }
+
+ function updateTitle($id,$title) {
+ $dbw=& wfGetDB(DB_MASTER);
+ $lowpri=$dbw->lowPriorityOption();
+ $searchindex = $dbw->tableName( 'searchindex' );
+
+ $sql = "UPDATE $lowpri $searchindex SET si_title='" .
+ $db->strencode( $title ) .
+ "' WHERE si_page={$id}";
+
+ $dbw->query( $sql, "SearchMySQL3::updateTitle" );
+ }
}
-?>
\ No newline at end of file
+?>
"FROM $cur,$searchindex " .
'WHERE cur_id=si_page AND ' . $match;
}
+
+ function update( $id, $title, $text ) {
+ $dbw=& wfGetDB(DB_MASTER);
+ $dbw->replace( 'searchindex', array(array('si_page')),
+ array(
+ 'si_page' => $id,
+ 'si_title' => $dbw->strencode($title),
+ 'si_text' => $dbw->strencode( $text )
+ ), 'SearchMySQL4::update' );
+ }
+
+ function updateTitle($id,$title) {
+ $dbw=& wfGetDB(DB_MASTER);
+ $lowpri=$dbw->lowPriorityOption();
+ $searchindex = $dbw->tableName( 'searchindex' );
+
+ $sql = "UPDATE $lowpri $searchindex SET si_title='" .
+ $db->strencode( $title ) .
+ "' WHERE si_page={$id}";
+
+ $dbw->query( $sql, "SearchMySQL4::updateTitle" );
+ }
+
}
-?>
\ No newline at end of file
+?>
wfProfileIn( $fname );
require_once( 'SearchEngine.php' );
- $lc = SearchEngine::legalSearchChars() . '&#;';
- $db =& wfGetDB( DB_MASTER );
- $searchindex = $db->tableName( 'searchindex' );
+ $search =& SearchEngine::create();
+ $lc = $search->legalSearchChars() . '&#;';
if( $this->mText == false ) {
- # Just update the title
- $lowpri = $db->lowPriorityOption();
- $sql = "UPDATE $lowpri $searchindex SET si_title='" .
- $db->strencode( Title::indexTitle( $this->mNamespace, $this->mTitle ) ) .
- "' WHERE si_page={$this->mId}";
- $db->query( $sql, "SearchUpdate::doUpdate" );
+ $search->updateTitle($this->mId,
+ Title::indexTitle( $this->mNamespace, $this->mTitle ));
wfProfileOut( $fname );
return;
}
# Strip wiki '' and '''
$text = preg_replace( "/''[']*/", " ", $text );
wfProfileOut( "$fname-regexps" );
- $db->replace( 'searchindex', array(array('si_page')),
- array(
- 'si_page' => $this->mId,
- 'si_title' => $db->strencode( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
- 'si_text' => $db->strencode( $text )
- ), 'SearchUpdate::doUpdate' );
+ $search->update($this->mId, Title::indexTitle( $this->mNamespace, $this->mTitle ),
+ $text);
wfProfileOut( $fname );
}
}
return;
}
- $search =& $this->getSearchEngine();
+ $search =& SearchEngine::create();
+ $search->setLimitOffset( $this->limit, $this->offset );
+ $search->setNamespaces( $this->namespaces );
$titleMatches = $search->searchTitle( $term );
$textMatches = $search->searchText( $term );
$wgOut->setArticleRelated( false );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
}
-
- /**
- * Load up the appropriate search engine class for the currently
- * active database backend, and return a configured instance.
- *
- * @return SearchEngine
- * @access private
- */
- function &getSearchEngine() {
- global $wgDBtype, $wgDBmysql4, $wgSearchType;
- if( $wgDBtype == 'mysql' ) {
- if( $wgDBmysql4 ) {
- $class = 'SearchMySQL4';
- require_once( 'SearchMySQL4.php' );
- } else {
- $class = 'SearchMysql3';
- require_once( 'SearchMySQL3.php' );
- }
- } else if ( $wgDBtype == 'PostgreSQL' ) {
- $class = 'SearchTsearch2';
- require_once( 'SearchTsearch2.php' );
- } else {
- $class = 'SearchEngineDummy';
- }
- $search = new $class( wfGetDB( DB_SLAVE ) );
- $search->setLimitOffset( $this->limit, $this->offset );
- $search->setNamespaces( $this->namespaces );
- return $search;
- }
/**
* Extract default namespaces to search from the given user's