Problem/Motivation

If subscription settings are not set (local variables and acquia cloud), 500 error and warnings in 'admin/config/search/apachesolr' will appear.

TypeError: array_keys(): Argument #1 ($array) must be of type array, bool given in array_keys() (line 264 of ../acquia_connector/acquia_search/src/PreferredSearchCoreService.php)

Warning: Trying to access array offset on value of type null in AcquiaSearchV3ApacheSolr->setUrl() (line 102 of ../acquia_connector/acquia_search/src/v3/AcquiaSearchV3ApacheSolr.php).

Warning: foreach() argument must be of type array|object, bool given in Drupal\acquia_search\PreferredSearchCoreService->getPreferredCore() (line 132 of ../acquia_connector/acquia_search/src/PreferredSearchCoreService.php).

This case is reproduced, when we install the deployed to Acquia cloud site locally and data from Acquia are missing.
This case is successfully handled in the previous version of the module (before 7.x-4.0), when we get a message:

Message: Sign up for Acquia Cloud Free, a free Drupal sandbox to experiment with new features, test your code quality, and apply continuous integration best practices. Check out the epic set of dev features and toolsthat come with your free subscription.If you have an Acquia Subscription, connect now. Otherwise, you can turn this message off by disabling the Acquia Subscription modules.'
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alena_stanul created an issue. See original summary.

alena_stanul’s picture

Issue summary: View changes
alena_stanul’s picture

Issue summary: View changes
alena_stanul’s picture

Issue summary: View changes

japerry’s picture

Version: 7.x-4.x-dev » 4.0.2
Status: Active » Postponed (maintainer needs more info)

I'd suggest trying 4.0.2 and seeing if it fixes this issue. we resolved a few problems with core detection between 4.0.1 and 4.0.2

mglaman’s picture

Version: 4.0.2 » 7.x-4.x-dev
mglaman’s picture

This is actually a 7.x-4.x issue, and should have been fixed in 7.x-4.2

alena_stanul’s picture

Issue summary: View changes
alena_stanul’s picture

Issue summary: View changes
alena_stanul’s picture

This case can be reproduced with other steps:
1) Enter an invalid Network key in 'admin/config/system/acquia-agent/credentials';
2) Click 'Connect' button.
3) Execute the 'drush cc all' command.
4) Reload page 'admin/config/search/apachesolr' twice.

It's a cache issue. After clearing the cache in case of empty or invalid keys $indexes will be false. Then the function will return an empty array, but in cache will store false. After the second reload, the return value of getCores will be false. This will throw a fatal error in array_keys().

alena_stanul’s picture

Status: Postponed (maintainer needs more info) » Needs review
alena_stanul’s picture

Issue summary: View changes
alena_stanul’s picture

Issue summary: View changes
renat33’s picture

Hello,

I've checked the fix made by @alena_stanul. Works great. 'admin/config/search/apachesolr' doesn't return 'TypeError:' error.

Thank you

mglaman’s picture

I see what I did before.

      $cid = 'acquia_search.indexes.' . $this->subscription;
      if (($cache = cache_get($cid))) {
        return $cache->data;
      }

cache_get is false on miss

        cache_set($cid, FALSE, 'cache', $now + 60);

Here I'm setting the data to false, not the same as a miss.

  • japerry committed 0396f837 on 7.x-4.x authored by alena_stanul
    Issue #3334091 by alena_stanul, japerry: TypeError: Argument #1 ($array...
mglaman’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.