[php-src] master: ext/curl: Use try conversion functions in curl (#24067)

From: Date: Tue, 06 Oct 2026 20:30:44 +0000
Subject: [php-src] master: ext/curl: Use try conversion functions in curl (#24067)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142035@lists.php.net to get a copy of this message
Author: Arshid (arshidkv12) Committer: GitHub (web-flow) Pusher: ndossche Date: 2026-10-06T22:30:40+02:00 Commit: https://github.com/php/php-src/commit/90a65ec8cbc6f093be131cf3248b2556bea39994 Raw diff: https://github.com/php/php-src/commit/90a65ec8cbc6f093be131cf3248b2556bea39994.diff ext/curl: Use try conversion functions in curl (#24067) Changed paths: A ext/curl/tests/curl_multi_exec_zval_conversion.phpt M NEWS M UPGRADING M ext/curl/multi.c Diff: diff --git a/NEWS b/NEWS index 07d329ef5a60..cc86611e0a3f 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.7.0alpha1 +- Curl: + . curl_multi_exec() now throws a TypeError when still_running is not an int. + (arshidkv12) + - FPM: . Use recommended TYPE, HELP order for OpenMetrics metadata. (Marcel Hernandez) diff --git a/UPGRADING b/UPGRADING index 87e614cca1c7..05ae834590c6 100644 --- a/UPGRADING +++ b/UPGRADING @@ -19,6 +19,9 @@ PHP 8.7 UPGRADE NOTES 1. Backward Incompatible Changes ======================================== +- Curl: + . curl_multi_exec() now throws a TypeError when still_running is not an int. + - PDO: . PDOStatement::bindColumn() now throws a ValueError when the column name is not present in the result set. It previously reported the condition diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 0e329e58f977..c8b15ba58f1f 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -254,8 +254,15 @@ PHP_FUNCTION(curl_multi_exec) _php_curl_verify_handlers(ch, /* reporterror */ true); } } + + bool failed; - still_running = zval_get_long(z_still_running); + still_running = zval_try_get_long(z_still_running, &failed); + if (UNEXPECTED(failed)) { + zend_argument_type_error(2, "must be of type int, %s given", zend_zval_value_name(z_still_running)); + RETURN_THROWS(); + } + error = curl_multi_perform(mh->multi, &still_running); ZEND_TRY_ASSIGN_REF_LONG(z_still_running, still_running); diff --git a/ext/curl/tests/curl_multi_exec_zval_conversion.phpt b/ext/curl/tests/curl_multi_exec_zval_conversion.phpt new file mode 100644 index 000000000000..85f9a44f6f9f --- /dev/null +++ b/ext/curl/tests/curl_multi_exec_zval_conversion.phpt @@ -0,0 +1,51 @@ +--TEST-- +curl_multi_exec(): zval conversion for still_running +--EXTENSIONS-- +curl +--FILE-- +<?php + +$mh = curl_multi_init(); + +$values = [ + '1', + 'abc', + 1.5, + true, + false, + null, + [], + new stdClass(), +]; + +foreach ($values as $value) { + $still_running = $value; + + try { + $result = curl_multi_exec($mh, $still_running); + + var_dump($result); + var_dump($still_running); + } catch (Throwable $e) { + echo get_class($e), ': ', $e->getMessage(), PHP_EOL; + } +} + +curl_multi_close($mh); +?> +--EXPECTF-- +int(0) +int(0) +TypeError: curl_multi_exec(): Argument #2 ($still_running) must be of type int, string given + +Deprecated: Implicit conversion from float 1.5 to int loses precision in %s on line %d +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +TypeError: curl_multi_exec(): Argument #2 ($still_running) must be of type int, array given +TypeError: curl_multi_exec(): Argument #2 ($still_running) must be of type int, stdClass given

« previous php.cvs (#142035) next »