Skip to content

⚠️ !Breaking Change! Use a separate configuration for each client - #23

Merged
pavog merged 1 commit into
masterfrom
separate-configuration
Oct 19, 2026
Merged

pavog merged 1 commit into
masterfrom
separate-configuration

Conversation

@pavog

@pavog pavog commented Oct 19, 2026

Copy link
Copy Markdown
Member

Clients created without a configuration used Configuration::getDefaultConfiguration(), which is a process wide singleton. All of these clients therefore shared one configuration:

$first = new CurseForgeAPIClient("first-api-token");
$second = new CurseForgeAPIClient("second-api-token");

$first->getGame(432); // was sent with "second-api-token"

The same applied to the user agent: calling setUserAgent() on one client changed it for all other clients.

Changes

  • CurseForgeAPIClient: creates a new Configuration() if none is passed, instead of using the default configuration.
  • Tests: two new tests check that clients without an explicit configuration do not share the API token or the user agent, and that an explicitly passed configuration is used. The test helper no longer passes its own configuration, so the default path is covered by all client tests.
  • setConfiguration() still sets the boolean query string format on the default configuration, because the generated ObjectSerializer reads it from there.

Behavior change

Changes made to Configuration::getDefaultConfiguration() (e.g. host or debug settings) no longer affect clients that are created without a configuration. To customize the configuration, pass it to the constructor:

$client = new CurseForgeAPIClient("api-key", $configuration);

@pavog
pavog requested a review from JulianVennen October 19, 2026 11:46

@JulianVennen JulianVennen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a breaking change

@pavog pavog added this to the v4.0.0 milestone Oct 19, 2026
@pavog pavog changed the title Use a separate configuration for each client ⚠️ !Breaking Change! Use a separate configuration for each client Oct 19, 2026
@pavog
pavog merged commit 71ea245 into master Oct 19, 2026
4 checks passed
@pavog
pavog deleted the separate-configuration branch October 19, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants