Remove database connection from REST client constructors

Created on 10 October 2024, 2 months ago

Problem/Motivation

REST clients currently require a database connection in their constructor. However, the connection is only used when a client has query limitations (::ensureQueryLimits()) set to keep track of request dates. If a client would like to handle limitations differently (ie. not using a database), then having a connection can become useless... and it is already useless for clients with no limitations. It complicates tests as the connection needs to be mocked.
Furthermore, not only REST clients may need to test limits between queries (or REST clients not derived from the base RestClient).

Proposed resolution

Remove the connection from the ExternalEntityType class properties and from its constructor. Use Drupal database service in ::ensureQueryLimits().

Move the ::ensureQueryLimits() method to a new trait "QueryLimitationTrait" that could be reused by other storage client plugins (not derived from the current RestClient base).

Remaining tasks

Please provide opinions on that change thanks.

User interface changes

None.

API changes

REST clients won't need a connection by default. Some existing REST clients (based on RestClient class) that have their own constructors will need to be updated.

Data model changes

None.

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France guignonv

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

Comments & Activities

Production build 0.71.5 2024