TL;DR: Solarium, as used by the acquia_search module, relies on some very specific handling for HTTP headers in PHP's file_get_contents(), but when there's a stream wrapper available for 'http://' streams, headers are treated differently. This means that the remote_stream_wrapper module (8.x-1.0 and 8.x-1.x-dev@d1f54fc6) breaks acquia_search. This can be solved by tweaking the Solarium usage in this module to use the Guzzle adapter; I've attached a patch.

The longer version:

The SearchApiSolrAcquiaConnector class specifies using Solarium's Solarium\Core\Client\Adapter\Http connection adapter instead of the default Curl adapter. This adapter class uses PHP's file_get_contents() function to fetch the contents of a URI; it looks for the HTTP headers to be populated by file_get_contents() in the $http_response_header variable.

However, when the remote_stream_wrapper module is enabled, file_get_contents() uses the Drupal\remote_stream_wrapper\StreamWrapper\HttpStreamWrapper class to read from the URI instead; this stream wrapper doesn't set the weird/ugly/vestigial $http_response_header variable to match PHP's core behavior. This means that Solarium no longer has access to the response headers, so SearchApiSolrAcquiaConnector can't tell whether it has reached the Acquia Solr server or authenticate against it.

Switching from Solarium's Http adapter to the Guzzle adapter removes the dependency on this quirky PHP behavior.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

becw created an issue. See original summary.

akalam’s picture

Status: Active » Needs review

Having same issue. Patch work for us.

janusman’s picture

Noting that this breaks search_api_attachments-8.x-1.x when using search_api_solr-8.x-1.x. (E.g., testing extraction at /admin/config/search/search_api_attachments fails with patch)

Status: Needs review » Needs work

The last submitted patch, acquia_search-use_solarium_guzzle.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • ayang committed 2ee12a8 on 8.x-1.x
    Issue #2891977 by becw, lcatlett, ayang: Updates Acquia Search to...
ayang’s picture

Status: Needs work » Fixed

Hello!

This has been added to the 8.x-1.x-dev branch. Related fixes for tests have also been committed to the dev branch to ensure that available tests pass with the latest Drupal version.

ayang credited lcatlett.

ayang’s picture

Status: Fixed » Closed (fixed)

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

janusman’s picture

Like I mentioned before, while this change did fix one thing, it indeed has broken attachment indexing (thru Search API Attachments module).

However, the root cause is the Guzzle adapter inside the Solarium 3.8.1 library having an issue--I have filed https://github.com/solariumphp/solarium/pull/653 in an attempt to get that fix into the Solarium 3.* branch.

IIUC if you were to install the latest 3.x version of Solarium and then apply the patch from https://patch-diff.githubusercontent.com/raw/solariumphp/solarium/pull/6... , you can get attachment indexing working again.

alison’s picture

@janusman Is there still a bug with search api attachments?