Skip to content

Fix curl_close() deprecation in PHP 8.5#254

Merged
samdark merged 4 commits intomasterfrom
copilot/fix-curl-close-usage
Jan 10, 2026
Merged

Fix curl_close() deprecation in PHP 8.5#254
samdark merged 4 commits intomasterfrom
copilot/fix-curl-close-usage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 10, 2026

Fix PHP 8.5 curl_close deprecation

  • Research PHP 8.5 changes for curl functions
  • Update CurlTransport::send() to conditionally call curl_close()
  • Update CurlTransport::batchSend() to conditionally call curl_multi_close()
  • Verify syntax and logic correctness
  • Request code review - passed with no issues
  • Run security check - passed
  • Add CHANGELOG entry

Summary

Fixed PHP 8.5 deprecation by conditionally calling curl_close() and curl_multi_close() only on PHP versions < 8.5. These functions are deprecated in PHP 8.5 because CurlHandle objects are automatically closed when they go out of scope (since PHP 8.0).

Changes Made

  • Added PHP_VERSION_ID < 80500 check before curl_close() call in send() method
  • Added PHP_VERSION_ID < 80500 check before curl_multi_close() call in batchSend() method
  • Added CHANGELOG entry documenting the fix

This maintains backwards compatibility with older PHP versions while preventing deprecation warnings on PHP 8.5+.

Original prompt

This section details on the original issue you should resolve

<issue_title>PHP 8.5 and curl_close usage</issue_title>
<issue_description>### Description

https://github.com/yiisoft/yii2-httpclient/blob/master/src/CurlTransport.php#L47 should not be called in PHP 8.5+

Package version

No response

PHP version

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix curl_close usage in PHP 8.5 and above Fix curl_close() deprecation in PHP 8.5 Jan 10, 2026
Copilot AI requested a review from samdark January 10, 2026 21:08
@samdark
Copy link
Copy Markdown
Member

samdark commented Jan 10, 2026

@copilot Add a line for CHANGELOG.

Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot Add a line for CHANGELOG.

Added CHANGELOG entry in commit 4a9f466.

@samdark samdark marked this pull request as ready for review January 10, 2026 23:59
Copilot AI review requested due to automatic review settings January 10, 2026 23:59
@samdark samdark merged commit 400dc61 into master Jan 10, 2026
21 of 24 checks passed
@samdark samdark deleted the copilot/fix-curl-close-usage branch January 10, 2026 23:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses PHP 8.5 deprecation warnings for curl_close() and curl_multi_close() functions by adding version checks to conditionally call these functions only on PHP versions prior to 8.5.

Changes:

  • Added PHP_VERSION_ID < 80500 conditional checks before curl_close() and curl_multi_close() calls
  • Updated CHANGELOG.md to document the bug fix

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/CurlTransport.php Added version checks to prevent deprecation warnings in PHP 8.5+ for curl_close() in send() method and curl_multi_close() in batchSend() method
CHANGELOG.md Added entry documenting the fix for issue #253

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

PHP 8.5 and curl_close usage

3 participants