Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/85889


Change subject: Extra guards around suggestion parsing.
......................................................................

Extra guards around suggestion parsing.

Bug: 54517
Change-Id: I03802f48653c8734a4fad3facd0b4bfdef6661c0
---
M CirrusSearchSearcher.php
1 file changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/89/85889/1

diff --git a/CirrusSearchSearcher.php b/CirrusSearchSearcher.php
index 87bf29e..93bf480 100644
--- a/CirrusSearchSearcher.php
+++ b/CirrusSearchSearcher.php
@@ -532,8 +532,12 @@
                        return null;
                }
                $suggest = $suggest[ 'suggest' ];
-               foreach ( $suggest[ CirrusSearchSearcher::SUGGESTION_NAME_TITLE 
][ 0 ][ 'options' ] as $option ) {
-                       return $option;
+               // Elasticsearch will send back the suggest element but no sub 
suggestion elements if the wiki is empty.
+               // So we should check to see if they exist even though in 
normal operation they always will.
+               if ( isset( $suggest[ 
CirrusSearchSearcher::SUGGESTION_NAME_TITLE ] ) ) {
+                       foreach ( $suggest[ 
CirrusSearchSearcher::SUGGESTION_NAME_TITLE ][ 0 ][ 'options' ] as $option ) {
+                               return $option;
+                       }
                }
                // If the user doesn't search against redirects we don't check 
them for suggestions so the result might not be there.
                if ( isset( $suggest[ 
CirrusSearchSearcher::SUGGESTION_NAME_REDIRECT ] ) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/85889
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03802f48653c8734a4fad3facd0b4bfdef6661c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <never...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to