Guard curl connection sharing when CURL_LOCK_DATA_CONNECT is undefined - #230
Open
plopesc wants to merge 1 commit into
Open
Guard curl connection sharing when CURL_LOCK_DATA_CONNECT is undefined#230plopesc wants to merge 1 commit into
plopesc wants to merge 1 commit into
Conversation
PHP only defines CURL_LOCK_DATA_CONNECT when its curl extension is built against libcurl 7.57.0 or newer. On older builds every ApiClient construction fataled with an undefined constant since 0.0.72. Skip the share handle when the constant is missing so those platforms fall back to one connection per request instead of failing. Fixes CyberSource#229
Author
|
Verified the patched client on the affected platform as promised:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #229.
PHP only defines
CURL_LOCK_DATA_CONNECTwhen its curl extension is built against libcurl 7.57.0 or newer. Since 0.0.72,ApiClient::__construct()uses the constant unconditionally, so on older builds (for example PHP 8.3 with libcurl 7.47 on Ubuntu 16.04, still common on managed hosting) every client instantiation throwsError: Undefined constant "CyberSource\CURL_LOCK_DATA_CONNECT".This change keeps connection sharing exactly as it is on supported builds and skips it on builds where the constant does not exist:
__construct(): create the share handle only whenCURL_LOCK_DATA_CONNECTis defined.callApi(): attachCURLOPT_SHAREonly when a share handle exists.Verified on PHP 8.3.31 / libcurl 8.14 (share handle still created, requests unchanged) and on PHP 8.3.30 / libcurl 7.47 (no fatal, requests succeed without connection sharing).