Skip to content

[HttpClient] cURL handles are not resources in php8 #37378

Closed
@derrabus

Description

@derrabus

Symfony version(s) affected: 5.1.2

Description
A console tool that I'm building uses the HttpClient component to query an API. It works perfectly fine of php 7.4, but if I run it on php 8 with ext-curl, I get the following error:

TypeError {#81
  #message: "curl_setopt(): Argument #1 ($handle) must be of type CurlHandle, null given"
  #code: 0
  #file: "./vendor/symfony/http-client/Response/CurlResponse.php"
  #line: 72
  trace: {
    ./vendor/symfony/http-client/Response/CurlResponse.php:72 { …}
    ./vendor/symfony/http-client/CurlHttpClient.php:311 { …}
    ./path/to/my/code { …}
  }
}

How to reproduce
The problem is apparently, that the code assumes that "curl handles" returned by curl_init() and curl_multi_init() are resources. However, in php 8 they're objects of type CurlHandle.

Possible Solution
Adjust CurlHttpClient and related classes to the new type of curl handles. I could work on a patch.

Additional Context
is_resource() is called on a handle:

A handle is cast to an int which does not work on objects:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions