WordPress / WordPress/Requests
[PHP8] curl_init can return false
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 500
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 5
Description
I don't think it's very likely, but curl_init can return false. Requests_Transport_cURL doesn't check that the return value is not false before calling curl_setopt. On PHP 8 this causes a fatal error.
Warning: Uncaught TypeError: curl_setopt(): Argument #1 ($handle) must be of type CurlHandle, bool given
Previously, this was just a PHP warning.
Warning: curl_setopt() expects parameter 1 to be resource, boolean given
I think we should probably check for $handle === false and throw a Requests_Exception.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Requests_Transport_cURL entry point and inspect the curl_init and curl_setopt flow described in the issue. Confirm the PHP 8 failure behavior, then verify that the completed change handles a false return and reports it through the library's exception path without triggering the fatal type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100