Skip to content

fix(cron): keep --user=0 in create, update and the scheduler config - #64

Open
mrrobot47 wants to merge 1 commit into
EasyEngine:developfrom
mrrobot47:fix/cron-user-zero
Open

mrrobot47 wants to merge 1 commit into
EasyEngine:developfrom
mrrobot47:fix/cron-user-zero

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

--user=0 (a valid uid for docker exec) passed validate_user() but was then lost to PHP and Mustache truthiness: create stored NULL, update <id> --user=0 alone failed with "You should specify at least one...", and next to other options it was silently ignored. The config.ini template's {{#user}} section also skipped a stored 0.

The user is now tested for presence instead of truthiness in create and update, the template renders it through a has_user flag, and the host and run-now paths no longer treat a stored 0 as no user.

Tested with PHPUnit on PHP 7.4 and 8.5: create stores and renders user 0, update accepts it alone and with other options, updating another field keeps it, moving the job to the host drops it, and run-now uses it.

Summary by CodeRabbit

  • Bug Fixes
    • Cron jobs now correctly preserve the user value 0 when creating or updating site jobs.
    • Run-now actions select root only when a job has no user set.
    • Generated configuration now includes a user setting for non-host jobs with a non-empty user value; host jobs and jobs without a user remain unchanged.

validate_user() accepts a uid of 0, but create stored NULL for it (if ( $user )), update refused it alone with "You should specify at least one..." and ignored it next to other options, and the config.ini template's {{#user}} section skips "0" because Mustache treats it as false. The user is now tested for presence, the template renders it through a has_user flag, and the host and run-now paths no longer treat a stored "0" as no user.
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Cron user handling

Layer / File(s) Summary
Cron command user values
src/Cron_Command.php
Creation and updates retain user value 0. Host-job checks and site-job defaults use explicit empty-string checks. Run-now falls back to root only when the stored user string is empty.
Generated user setting
src/helper/utils.php, templates/config.ini.mustache
Configuration generation sets has_user for non-host jobs with a nonempty user. The template uses this flag to conditionally emit the user setting.

Suggested reviewers: kirtangajjar

Change: Bug fix

Merge Risk: Minimal · up to 1b1ad

This change keeps a cron user of 0 through create, update, generated configuration and run-now instead of dropping it. The change is small and localized. No concrete merge-blocking risk was found.

Security architecture risk: Minimal · up to 1b1ad

Preserving UID 0 honors an already supported execution identity without adding a new privilege class or weakening host-job restrictions. No materially increased security, ownership, or recovery risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed user value reaches the selected site's PHP-container job configuration and docker exec invocation. Configuration regeneration nevertheless remains shared across all stored jobs and restarts the common scheduler.

Trust Boundaries and Controls

  • inferred — Preserving numeric UID 0 does not introduce an additional execution privilege class: root selection was already supported, and run-now previously substituted root for a stored 0. The changed branches retain validation and host-job restrictions rather than opening another route to host execution.

Resilience and Maintainability Implications

  • observed — Configuration generation retains its existing per-job INI-safety checks and omission behavior. The new eligibility flag changes whether a validated user setting is rendered; it does not remove the checks protecting the shared scheduler configuration.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1cb3f7e0-d32b-4fd0-982a-09109322fb4b
Commits

Reviewing files that changed from the base of the PR and between e674c8e and 1b1ad93.

Files selected for processing: 3

  • src/Cron_Command.php
  • src/helper/utils.php
  • templates/config.ini.mustache

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

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.

1 participant