monolog icon indicating copy to clipboard operation
monolog copied to clipboard

PHP 8.5: Don't use deprecated `curl_close()` on PHP >= 8.0.0

Open mpesari opened this issue 3 months ago • 0 comments

curl_close() is noop since 8.0.0 and emites E_DEPRECATED since 8.5.0.

It's used in Monolog\Handler\Curl\Util::execute() if $closeAfterDone = true.

It's the same for 1.x, 2.x and 3.x.

On 3.x we could just drop the $closeAfterDone parameter, but that might lead to backport difficulties.

One suggestion would be to check PHP_VERSION_ID on the top of the affected function:

// src/Monolog/Handler/Curl/Util.php

    public static function execute(CurlHandle $ch, int $retries = 5, bool $closeAfterDone = true): bool|string
    {
        if (\PHP_VERSION_ID >= 80000) {
            $closeAfterDone = false;
        }

        // ...
    }

This would retain similar code in all branches until old versions are dropped.

  • https://www.php.net/curl_close
  • https://github.com/php/php-src/blob/php-8.0.0/UPGRADING#L1016-L1020
  • https://github.com/php/php-src/blob/php-8.5.0/UPGRADING#L416-L418

mpesari avatar Nov 25 '25 20:11 mpesari