localgovdrupal / localgov_search

Default sitewide search implementation for LocalGov Drupal.
GNU General Public License v2.0
0 stars 1 forks source link

Check index is loaded before checking index->status #70

Open finnlewis opened 8 months ago

finnlewis commented 8 months ago

See https://github.com/localgovdrupal/localgov_search/blob/1.x/src/Plugin/Block/SitewideSearchBlock.php#L81-L82

    $index = Index::load('localgov_sitewide_search');
    if (!$index->status()) {

In https://github.com/localgovdrupal/localgov_microsites_group/pull/438/ we are testing the upgrade path of localgov_microsites_group and hitting some permissions issues.

One apparent side-effect of this is that the localgov_sitewide_search index is not being loaded.

This causes an error on the if() chec above.

I think it might be good to make this a little more resiliant with

    $index = Index::load('localgov_sitewide_search');
    if ($index && !$index->status()) {

Or something more specific....

if ($index instanceof IndexInterface && !$index->status())