From f9039cefd9f5bf6d497e62c03a84305293901f6d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 23 May 2005 05:25:26 +0000 Subject: [PATCH] Spacing; use Title::exists --- includes/SearchEngine.php | 55 +++++++++++++++++++-------------------- includes/SearchMySQL3.php | 16 ++++++------ includes/SearchMySQL4.php | 36 ++++++++++++------------- 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 8ae7e6ec91..623f12bf92 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -51,28 +51,28 @@ class SearchEngine { function getNearMatch( $term ) { # Exact match? No need to look further. $title = Title::newFromText( $term ); - if ( $title->getNamespace() == NS_SPECIAL || 0 != $title->getArticleID() ) { + if ( $title->getNamespace() == NS_SPECIAL || $title->exists() ) { return $title; } # Now try all lower case (i.e. first letter capitalized) # $title = Title::newFromText( strtolower( $term ) ); - if ( 0 != $title->getArticleID() ) { + if ( $title->exists() ) { return $title; } # Now try capitalized string # $title = Title::newFromText( ucwords( strtolower( $term ) ) ); - if ( 0 != $title->getArticleID() ) { + if ( $title->exists() ) { return $title; } # Now try all upper case # $title = Title::newFromText( strtoupper( $term ) ); - if ( 0 != $title->getArticleID() ) { + if ( $title->exists() ) { return $title; } @@ -226,32 +226,31 @@ class SearchEngine { /** * Load up the appropriate search engine class for the currently - * active database backend, and return a configured instance. - * - * @return SearchEngine - * @access private - */ + * 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; + 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; } - } diff --git a/includes/SearchMySQL3.php b/includes/SearchMySQL3.php index 948c97b6c9..a03a554eb7 100644 --- a/includes/SearchMySQL3.php +++ b/includes/SearchMySQL3.php @@ -93,12 +93,12 @@ class SearchMySQL3 extends SearchEngine { function update( $id, $title, $text ) { $dbw=& wfGetDB(DB_MASTER); - $dbw->replace( 'searchindex', array(array('si_page')), - array( - 'si_page' => $id, - 'si_title' => $title, - 'si_text' => $text - ), 'SearchMySQL3::update' ); + $dbw->replace( 'searchindex', array(array('si_page')), + array( + 'si_page' => $id, + 'si_title' => $title, + 'si_text' => $text + ), 'SearchMySQL3::update' ); } function updateTitle($id,$title) { @@ -107,8 +107,8 @@ class SearchMySQL3 extends SearchEngine { $searchindex = $dbw->tableName( 'searchindex' ); $sql = "UPDATE $lowpri $searchindex SET si_title='" . - $dbw->strencode( $title ) . - "' WHERE si_page={$id}"; + $dbw->strencode( $title ) . + "' WHERE si_page={$id}"; $dbw->query( $sql, "SearchMySQL3::updateTitle" ); } diff --git a/includes/SearchMySQL4.php b/includes/SearchMySQL4.php index 20bbfbcfc5..2e19096a54 100644 --- a/includes/SearchMySQL4.php +++ b/includes/SearchMySQL4.php @@ -91,27 +91,27 @@ class SearchMySQL4 extends SearchEngine { } /** @todo document */ - function update( $id, $title, $text ) { - $dbw=& wfGetDB(DB_MASTER); - $dbw->replace( 'searchindex', array(array('si_page')), - array( - 'si_page' => $id, - 'si_title' => $title, - 'si_text' => $text - ), 'SearchMySQL4::update' ); - } + function update( $id, $title, $text ) { + $dbw=& wfGetDB(DB_MASTER); + $dbw->replace( 'searchindex', array(array('si_page')), + array( + 'si_page' => $id, + 'si_title' => $title, + 'si_text' => $text + ), 'SearchMySQL4::update' ); + } /** @todo document */ function updateTitle($id,$title) { - $dbw=& wfGetDB(DB_MASTER); - $lowpri=$dbw->lowPriorityOption(); - $searchindex = $dbw->tableName( 'searchindex' ); + $dbw =& wfGetDB(DB_MASTER); + $lowpri = $dbw->lowPriorityOption(); + $searchindex = $dbw->tableName( 'searchindex' ); - $sql = "UPDATE $lowpri $searchindex SET si_title='" . - $dbw->strencode( $title ) . - "' WHERE si_page={$id}"; + $sql = "UPDATE $lowpri $searchindex SET si_title='" . + $dbw->strencode( $title ) . + "' WHERE si_page={$id}"; - $dbw->query( $sql, "SearchMySQL4::updateTitle" ); - } + $dbw->query( $sql, "SearchMySQL4::updateTitle" ); + } } -?> \ No newline at end of file +?> -- 2.20.1