Handle search engine returning status objects to the API
authorChad Horohoe <chadh@wikimedia.org>
Thu, 18 Apr 2013 15:29:21 +0000 (11:29 -0400)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 22 Apr 2013 01:13:24 +0000 (01:13 +0000)
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

index 8618339..ab78ba6 100644 (file)
@@ -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' ),
                ) );
        }