Unverified Commit c85fb759 authored by Matt Glaman's avatar Matt Glaman Committed by GitHub
Browse files

Issue #3313861 by balintpekker: Add null protector to PreferredCodeService (#32)

* Issue #3313861: Added null protector to getPreferredCore()

* Issue #3313861: Return empty array instead of NULL to prevent warnings

* Apply 1 suggestion(s) to 1 file(s)

Co-authored-by: default avatarBalint Pekker <balint.pekker@cheppers.com>
Co-authored-by: default avatarmglaman <mglaman@2416470.no-reply.drupal.org>
parent c717f66b
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -76,17 +76,14 @@ class PreferredCoreService {
   * Returns core IDs available in subscription.
   */
  public function getAvailableCores() {
    if (!$cores = $this->acquiaSearchApiClient->getSearchIndexes()) {
      // Throw exception?
      return NULL;
    }

    // Able to connect, however no cores were found return empty instead.
    // When there was an Acquia Search API failure, or we are able to connect,
    // however no cores were found return an empty array.
    $cores = $this->acquiaSearchApiClient->getSearchIndexes();
    if (empty($cores)) {
      return [];
    }

    // We user core id as a key.
    // We use core id as a key.
    return $cores;
  }