Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy