Have ElasticSearchConnectorInterface::getClient() return an Elasticsearch ClientInterface instead of a Client

Created on 25 June 2025, 3 days ago

Problem/Motivation

Currently, \Drupal\elasticsearch_connector\Connector\ElasticSearchConnectorInterface::getClient()'s signature returns a \Elastic\Elasticsearch\Client.

But making the signature specify the Client instead of its interface, (i.e.: \Elastic\Elasticsearch\ClientInterface) makes it difficult to substitute a test double. Being able to substitute a test double would make it easier to write automated tests.

Proposed resolution

Change the method signature to return a \Elastic\Elasticsearch\ClientInterface instead of a \Elastic\Elasticsearch\Client. Note that Symfony considers changing the type of a public method a backwards-compatibility break.

Remaining tasks

  1. Write a patch:
    1. Change the return type of \Drupal\elasticsearch_connector\Connector\ElasticSearchConnectorInterface::getClient()
    2. Change the return type of \Drupal\elasticsearch_connector\Plugin\ElasticSearch\Connector\BasicAuthConnector::getClient()
    3. Change the return type of \Drupal\elasticsearch_connector\Plugin\ElasticSearch\Connector\StandardConnector::getClient()
    4. If Connect to an Elastic Cloud Hosted Deployment acting as a Search API Server by entering a Cloud ID and API key Active is merged, change the return types of the two connectors added in that issue.
  2. Add a draft change record
  3. Review and feedback
  4. RTBC and feedback
  5. Commit
  6. Publish change record
  7. Release

User interface changes

None.

API changes

Yes, see above. Note this issue would introduce a backwards-compatibility break, and thus would need to happen on a major version release.

Data model changes

None.

Feature request
Status

Active

Version

8.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024