Skip to content

Fix/schedule cron review findings - #129

Merged
benkhalife merged 4 commits into
masterfrom
fix/schedule-cron-review-findings
Sep 25, 2026
Merged

benkhalife merged 4 commits into
masterfrom
fix/schedule-cron-review-findings

Conversation

@benkhalife

Copy link
Copy Markdown
Member

No description provided.

isDue() combined all five cron fields with AND, so an expression like
"0 9 1 * 1" (meant to mean "9am on the 1st of the month OR every
Monday", per standard cron) only matched on the rare day that was
both at once — a silent behavior mismatch for anyone coming from
standard crontab semantics.

Track whether the day-of-month/day-of-week fields were literally
restricted (not the bare "*"), and OR them together when both are;
otherwise keep the existing AND (the unrestricted field is always
true, so the two agree, no special-casing needed).
4 tests: both-restricted fields OR together (e.g. "0 9 1 * 1"),
either field alone still acts as AND against a wildcard sibling, and
a step field (e.g. "*/2") still counts as "restricted" for this rule.
[ClassName::class, 'method'] only worked when "method" was static:
is_callable() is false for a class-string paired with an instance
method, so the documented array-callback form threw "Scheduled task
callback is not callable." for the common case of a regular
(non-static) method.

Instantiate the class ourselves in that case, same as 'Class@method'
already did, so both forms work identically regardless of whether
the method is static. Since there's no dependency container here,
that instantiation still only supports a no-argument constructor —
but a class that needs one now fails with a clear, actionable
RuntimeException pointing at the [$instance, 'method'] workaround,
instead of a bare ArgumentCountError leaking out of `new $class()`.
Documented both the supported forms and this limitation on
ScheduleEvent's constructor.
5 tests: [Class::class, method] now works for non-static methods,
still works for static ones, 'Class@method' still works, a class
needing constructor arguments fails with an actionable message, and
the documented workaround (pre-built instance) bypasses that limit.
@benkhalife
benkhalife merged commit 8d12dc6 into master Sep 25, 2026
2 checks passed
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