Title: Search: Fix the issue raised when trying to randomly determine Elasticsearch host but no hosts available.
Author: WordPress VIP Documentation
Published: March 9, 2021
Last modified: August 5, 2025

---

 1. [Changelog](https://docs.wpvip.com/changelog/)
 2. [VIP MU plugins [Production]](https://docs.wpvip.com/changelog/vip-mu-plugins-production/)
 3. Search: Fix the issue raised when trying to randomly determine Elasticsearch host
    but no hosts available.

# Search: Fix the issue raised when trying to randomly determine Elasticsearch host but no hosts available.

---

 09 March 2021

16:23:01 GMT+0000

 [ VIP MU plugins [Production] ](https://docs.wpvip.com/changelog/vip-mu-plugins-production/)

 [ Permalink  ](https://docs.wpvip.com/changelog/vip-mu-plugins-production/search-fix-the-issue-raised-when-trying-to-randomly-determine-elasticsearch-host-but-no-hosts-available/)

PHP `array_rand()` functions require a non-empty array, and it will raise a PHP 
warning in PHP 7.1-7.4 and a fatal error in PHP 8 in the case the array is empty.

[https://github.com/Automattic/vip-go-mu-plugins/pull/2019](https://github.com/Automattic/vip-go-mu-plugins/pull/2019)