* @file
*/
-use MediaWiki\MediaWikiServices;
-
/**
* Query module to perform full text search within wiki titles and content
*
// Deprecated parameters
if ( isset( $prop['hasrelated'] ) ) {
- $this->logFeatureUsage( 'action=search&srprop=hasrelated' );
- $this->setWarning( 'srprop=hasrelated has been deprecated' );
+ $this->addDeprecation(
+ [ 'apiwarn-deprecation-parameter', 'srprop=hasrelated' ], 'action=search&srprop=hasrelated'
+ );
}
if ( isset( $prop['score'] ) ) {
- $this->logFeatureUsage( 'action=search&srprop=score' );
- $this->setWarning( 'srprop=score has been deprecated' );
+ $this->addDeprecation(
+ [ 'apiwarn-deprecation-parameter', 'srprop=score' ], 'action=search&srprop=score'
+ );
}
// Create search engine instance and set options
$search = $this->buildSearchEngine( $params );
$search->setFeatureData( 'rewrite', (bool)$params['enablerewrites'] );
+ $search->setFeatureData( 'interwiki', (bool)$interwiki );
$query = $search->transformSearchTerm( $query );
$query = $search->replacePrefixes( $query );
$matches = $search->searchText( $query );
}
}
- if ( is_null( $matches ) ) {
- $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" );
- } elseif ( $matches instanceof Status && !$matches->isGood() ) {
- $this->dieUsage( $matches->getWikiText( false, false, 'en' ), 'search-error' );
+
+ if ( $matches instanceof Status ) {
+ $status = $matches;
+ $matches = $status->getValue();
+ } else {
+ $status = null;
+ }
+
+ if ( $status ) {
+ if ( $status->isOK() ) {
+ $this->getMain()->getErrorFormatter()->addMessagesFromStatus(
+ $this->getModuleName(),
+ $status
+ );
+ } else {
+ $this->dieStatus( $status );
+ }
+ } elseif ( is_null( $matches ) ) {
+ $this->dieWithError( [ 'apierror-searchdisabled', $what ], "search-{$what}-disabled" );
}
if ( $resultPageSet === null ) {