API: Don't use an empty LinkBatch in ApiOpenSearch
[lhc/web/wiklou.git] / includes / api / ApiOpenSearch.php
index 4a9e216..3b56dec 100644 (file)
@@ -59,7 +59,7 @@ class ApiOpenSearch extends ApiBase {
        }
 
        public function getCustomPrinter() {
-               switch( $this->getFormat() ) {
+               switch ( $this->getFormat() ) {
                        case 'json':
                                return $this->getMain()->createPrinterByName( 'json' . $this->fm );
 
@@ -124,6 +124,9 @@ class ApiOpenSearch extends ApiBase {
                // Find matching titles as Title objects
                $searcher = new TitlePrefixSearch;
                $titles = $searcher->searchWithVariants( $search, $limit, $namespaces );
+               if ( !$titles ) {
+                       return;
+               }
 
                if ( $resolveRedir ) {
                        // Query for redirects