From ea430cba3d7999e39f77833e19456a4abac840dc Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 18 Apr 2013 11:29:21 -0400 Subject: [PATCH] Handle search engine returning status objects to the API This is a followup to I54ab5207, which allowed search backends to return status objects. We handled it in Special:Search, but the API was overlooked. Bug: 47353 Change-Id: Ib7abe8d5bc19d27c472053602c0e43cb1301b078 --- includes/api/ApiQuerySearch.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 861833919b..ab78ba6710 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -93,6 +93,8 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } if ( is_null( $matches ) ) { $this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" ); + } elseif( $matches instanceof Status && !$matches->isGood() ) { + $this->dieUsage( $matches->getWikiText(), 'search-error' ); } $apiResult = $this->getResult(); @@ -345,6 +347,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'search-text-disabled', 'info' => 'text search is disabled' ), array( 'code' => 'search-title-disabled', 'info' => 'title search is disabled' ), + array( 'code' => 'search-error', 'info' => 'search error has occurred' ), ) ); } -- 2.20.1