Skip to content

Fix deprecation on PHP 8.5#350

Open
VincentLanglet wants to merge 2 commits intoworkos:mainfrom
VincentLanglet:curlClose
Open

Fix deprecation on PHP 8.5#350
VincentLanglet wants to merge 2 commits intoworkos:mainfrom
VincentLanglet:curlClose

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

Hi @gjtorikian @sheldonvaughn,

Description

Since PHP8.5 curl_close is deprecated and the call is only useful for PHP 7.
https://www.php.net/manual/en/function.curl-close.php

This prevent the deprecation

Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0

It would be great having a patch release with this.

Documentation

Does not require change to the doc

@VincentLanglet VincentLanglet requested review from a team as code owners March 31, 2026 09:49
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR addresses the PHP 8.5 deprecation of curl_close() by guarding both call sites inside CurlRequestClient::execute() with a PHP_VERSION_ID < 80000 version check, so the function is only invoked on PHP 7.x where it still has an effect (releasing the curl resource handle). On PHP 8.0+ curl handles became objects and are garbage-collected automatically, making curl_close() a no-op; PHP 8.5 formalised this by deprecating the function entirely.

  • The boundary PHP_VERSION_ID < 80000 is precisely correct: PHP 8.0.0 is represented as 80000, so the guard fires only for PHP 7.x, which aligns with the project's declared minimum of PHP >=7.3.0.
  • Both call sites (error path and success path) are updated consistently, so there is no resource-leak regression on PHP 7.x.
  • No functional behavior changes are introduced; the change only suppresses the deprecation notice on PHP 8.5+.

Confidence Score: 5/5

This PR is safe to merge; it is a minimal, correct fix with no functional or behavioral changes.

The change is two identical, symmetric guard blocks around a deprecated no-op function call. The version boundary is correct, both code paths (error and success) are updated, and the fix is fully consistent with the project's PHP >=7.3 support contract. No P0 or P1 issues were found.

No files require special attention.

Important Files Changed

Filename Overview
lib/RequestClient/CurlRequestClient.php Wraps both curl_close() call sites in a PHP_VERSION_ID < 80000 guard to suppress the PHP 8.5 deprecation warning; logic is correct and backward-compatible with the declared PHP >=7.3 minimum.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[curl_exec] --> B{result === false?}
    B -- Yes --> C[curl_errno / curl_error]
    C --> D{PHP_VERSION_ID < 80000?}
    D -- Yes PHP 7.x --> E[curl_close]
    D -- No PHP 8.0+ --> F[skip curl_close]
    E --> G[throw GenericException]
    F --> G
    B -- No --> H[curl_getinfo status code]
    H --> I{PHP_VERSION_ID < 80000?}
    I -- Yes PHP 7.x --> J[curl_close]
    I -- No PHP 8.0+ --> K[skip curl_close]
    J --> L[return result/headers/statusCode]
    K --> L
Loading

Reviews (1): Last reviewed commit: "PHP 8" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant