[php-src] master: standard: Fix error reporting for negative timeouts in `Io\Poll\Context::wait()` (#23099)

From: Date: Fri, 07 Aug 2026 13:19:53 +0000
Subject: [php-src] master: standard: Fix error reporting for negative timeouts in `Io\Poll\Context::wait()` (#23099)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140528@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Committer: GitHub (web-flow) Pusher: TimWolla Date: 2026-08-07T15:19:48+02:00 Commit: https://github.com/php/php-src/commit/0380f2577f36728c0ff942556ffa6f3976b60297 Raw diff: https://github.com/php/php-src/commit/0380f2577f36728c0ff942556ffa6f3976b60297.diff standard: Fix error reporting for negative timeouts in Io\Poll\Context::wait() (#23099) Changed paths: A ext/standard/tests/poll/poll_ctx_wait.phpt M ext/standard/io_poll.c Diff: diff --git a/ext/standard/io_poll.c b/ext/standard/io_poll.c index c29ccfee04f2..f57813874d52 100644 --- a/ext/standard/io_poll.c +++ b/ext/standard/io_poll.c @@ -791,7 +791,7 @@ PHP_METHOD(Io_Poll_Context, wait) struct timespec timeout_ts; if (timeout) { if (timeout->duration.negative) { - zend_argument_value_error(2, "must not be negative"); + zend_argument_value_error(1, "must not be negative"); RETURN_THROWS(); } diff --git a/ext/standard/tests/poll/poll_ctx_wait.phpt b/ext/standard/tests/poll/poll_ctx_wait.phpt new file mode 100644 index 000000000000..5080c1421fdb --- /dev/null +++ b/ext/standard/tests/poll/poll_ctx_wait.phpt @@ -0,0 +1,24 @@ +--TEST-- +Io\Poll\Context::wait(): Parameter validation +--FILE-- +<?php +require_once __DIR__ . '/poll.inc'; + +$poll_ctx = new Io\Poll\Context(); + +try { + $poll_ctx->wait(timeout: Time\Duration::fromSeconds(1)->negate()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + $poll_ctx->wait(maxEvents: -1); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ValueError: Io\Poll\Context::wait(): Argument #1 ($timeout) must not be negative +ValueError: Io\Poll\Context::wait(): Argument #2 ($maxEvents) must be greater than 0

« previous php.cvs (#140528) next »