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.'
Comments
Comment #2
alena_stanul commentedComment #3
alena_stanul commentedComment #4
alena_stanul commentedComment #6
japerryI'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
Comment #7
mglamanComment #8
mglamanThis is actually a 7.x-4.x issue, and should have been fixed in 7.x-4.2
Comment #9
alena_stanul commentedComment #10
alena_stanul commentedComment #11
alena_stanul commentedThis 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().
Comment #12
alena_stanul commentedComment #13
alena_stanul commentedComment #14
alena_stanul commentedComment #15
renat33 commentedHello,
I've checked the fix made by @alena_stanul. Works great. 'admin/config/search/apachesolr' doesn't return 'TypeError:' error.
Thank you
Comment #16
mglamanI see what I did before.
cache_get is false on miss
Here I'm setting the data to false, not the same as a miss.
Comment #18
mglaman