Skip to content

fix(config): reject processes values below 1 - #1192

Open
rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-20261111-processes-min
Open

rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:fix-20261111-processes-min

Conversation

@rootsiemen

Copy link
Copy Markdown
Contributor

Closes #1182

What changed

  • servers.*.processes now has ->min(1) in ConfigurationTreeBuilder (keeps defaultNull): 0 and negative values are rejected at config validation with a clear InvalidConfigurationException instead of passing through.
  • Added config tests: reject processes: 0 and processes: -1, accept the boundary 1 and the null default (one field per process() call, per FAQ-035).
  • CHANGELOG entry under [Unreleased] -> Fixed.

Why

ServerWorker passes the value straight to Worker::$count, and Workerman silently clamps it to one worker — so a typo like processes: 0 produced a running server with no visible error. Failing fast at config load surfaces the mistake immediately.

SupervisorWorker's <= 0 filter was left untouched: it guards a different path (the #[AsProcess] attribute processes, not the servers.*.processes config node), so it stays as defense-in-depth for programmatic config.

Tests

  • ConfigurationTreeBuilderTest (new tests first failed pre-fix, proving the bug: 0/-1 passed validation; after the fix all pass): 3/3 new tests green.
  • Targeted suites with a fresh composer install: ConfigurationTreeBuilderTest + SupervisorWorkerTest 69/69 green; ServerWorkerTest 44/46 — the 2 failures (testUnreadableCertThrowsException, testUnreadableKeyThrowsException) also fail on pristine master: the suite runs as root, so chmod-000 cert/key files stay readable (pre-existing, unrelated).
  • composer lint: php-cs-fixer, PHPStan level 8, Rector, kb-lint, check-changelog, exception-usage and upgrade-exceptions all OK. Two pre-existing failures unrelated to this diff: shellcheck SC2015 (info) in the shared bin/worktree-done.sh (byte-identical script, must not be edited) and hadolint not installed in this environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] servers.*.processes accepts 0 and negative values; Workerman silently clamps them to one worker

1 participant