From: Jens Frank Date: Wed, 8 Sep 2004 22:01:58 +0000 (+0000) Subject: ENH#208 Updated: X-Git-Tag: 1.5.0alpha1~2052 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=bbbbeb256f939903adf8062137697b144a0ea1d0;p=lhc%2Fweb%2Fwiklou.git ENH#208 Updated: * using searchindex * client.php can only be called using the cli * upon first sight, nusoap seems to be utf8-clean. search query for utf8 strings succeeded. --- diff --git a/soap/client.php b/soap/client.php index 2efa4cb3b6..b9d75cfd2a 100644 --- a/soap/client.php +++ b/soap/client.php @@ -1,10 +1,16 @@ call( 'echoString', array( $t ) ); @@ -30,7 +36,7 @@ print_r( $r ); print( "Error: ".$s->getError() . "\n" ); print "\n\n==searchTitles==\n"; -$r = $s->call( 'searchTitles', array( 'furt', 1 ) ); +$r = $s->call( 'searchTitles', array( 'Frankfurt', 0 ) ); print_r( $r ); print( "Error: ".$s->getError() . "\n" ); diff --git a/soap/index.php b/soap/index.php index 2429a0ce91..6d4c45211d 100644 --- a/soap/index.php +++ b/soap/index.php @@ -29,7 +29,7 @@ unset( $IP ); @ini_set( "allow_url_fopen", 0 ); # For security... if(!file_exists("../LocalSettings.php")) { - die( "You'll have to set the wiki up first!" ); + die( "You'll have to set the wiki up first!" ); } define( "MEDIAWIKI", true ); @@ -313,13 +313,19 @@ function searchTitles( $pattern, $main_only ) { if ( $main_only != 0 && $main_only != 1 ) { return new soap_fault('Client', 'The second parameter to this service must be 0 or 1'); } + - # Query the DB + # Connect to the DB $dbr =& wfGetDB( DB_SLAVE ); - $sql = 'SELECT cur_title, cur_namespace FROM cur WHERE ' + # Normalize the search pattern + $pattern = $dbr->strencode( $wgLang->stripForSearch( $pattern ) ); + + # Prepare the query + + $sql = 'SELECT cur_id, cur_namespace, cur_title FROM cur, searchindex WHERE ' . ( $main_only ? 'cur_namespace=0 AND ' :'' ) - . "cur_title like '%".$dbr->strencode($pattern)."%'"; + . "cur_id=si_page AND MATCH(si_title) AGAINST('{$pattern}' IN BOOLEAN MODE)"; $res = $dbr->query( $sql, $fname, true ); @@ -328,11 +334,11 @@ function searchTitles( $pattern, $main_only ) { } $answer = array( - 'count' => 1, + 'count' => 0, 'base' => $wgServer.$wgArticlePath, - 'hits' => array() + 'hits' => array(), ); - while ( $line = $dbr->fetchObject( $res ) && $answer['count'] < 200 ) { + while ( ($line = $dbr->fetchObject( $res )) && $answer['count'] < 200 ) { $nt = Title::newFromDBkey( $wgLang->getNsText( $line->cur_namespace ) . ':' . $line->cur_title ); $answer['hits'][] = array( 'title' => $nt->getText(),