| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
- TaskScheduler::scheduleTask now converts the \DateTime returned by
Cron\CronExpression::getNextRunDate() to \DateTimeImmutable before
calling TaskExecutionRepositoryInterface::create(), which contractually
requires \DateTimeImmutable. Without this, every cron-driven schedule
fails with a TypeError when the repository enforces the parameter type.
- TaskExecution::getResult() returns null when the result column was
never set, instead of false (unserialize(null) === false in PHP 8).
- Repair pre-existing syntax errors ("new \\DateTimeImmutable))" and
"new \\DateTimeImmutable)'...')") that were left in the test suite by
the sed-based DateTime → DateTimeImmutable migration in php-task#52, which
made the whole tests/Unit/Execution and tests/Unit/Storage suites
un-loadable.
- Update remaining tests that still called the removed findAll() method
to use findAllPaginated(1).
ubuntu-20.04 has been retired; jobs hang waiting for a runner. See: https://github.blog/changelog/2025-01-15-github-actions-ubuntu-20-runner-image-brownout-dates-and-other-breaking-changes/
There was a problem hiding this comment.
This PR fixes a runtime TypeError in cron-based scheduling by normalizing cron-derived schedule times to \DateTimeImmutable, and restores the unit test suite by repairing migration-introduced syntax errors and updating tests to the current repository API.
Changes:
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file| File | Description |
|---|---|
| src/Task/Scheduler/TaskScheduler.php | Normalizes mutable cron schedule times to \DateTimeImmutable to satisfy repository contract. |
| src/Task/Execution/TaskExecution.php | Returns null for unset results before unserializing stored values. |
| tests/Unit/Scheduler/TaskSchedulerTest.php | Updates mock expectations to match immutable schedule time passed to repository. |
| tests/Unit/Execution/TaskExecutionTest.php | Fixes syntax errors introduced by prior DateTimeImmutable migration. |
| tests/Unit/Storage/ArrayStorage/ArrayTaskRepositoryTest.php | Replaces removed findAll() usage with findAllPaginated(1). |
| tests/Unit/Storage/ArrayStorage/ArrayTaskExecutionRepositoryTest.php | Fixes syntax errors and updates findAll() usage to findAllPaginated(1). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
- TaskExecutionInterface::getResult() PHPDoc now documents the null return possibility introduced by the unset-result fix. - Rename leftover testFindAll() methods to testFindAllPaginatedUnbounded() so the test name matches the API being exercised.
Accidentally included in the previous commit; add it to .gitignore.
| Back | FazBrowse Home | New Git URL |
What's in this PR?
TaskScheduler::scheduleTask now converts the mutable \DateTime returned by Cron\CronExpression::getNextRunDate() to \DateTimeImmutable before passing it to TaskExecutionRepositoryInterface::create(). The interface declares the parameter as \DateTimeImmutable, so every cron-driven schedule currently raises TypeError when the implementation enforces the contract.
TaskExecution::getResult() returns null when the result column was never set, instead of false (since unserialize(null) === false on PHP 8).
Pre-existing syntax errors introduced by the sed-based DateTime → DateTimeImmutable migration in Enhance doctrine compatability #52 are repaired (new \DateTimeImmutable)) and new \DateTimeImmutable)'...')). These were making the whole tests/Unit/Execution and tests/Unit/Storage/ArrayStorage suites un-loadable.
Remaining test calls to the removed findAll() method are updated to findAllPaginated(1).
Why?
CI in php-task/TaskBundle#60 hit TypeError: TaskExecutionRepository::create(): Argument #2 ($scheduleTime) must be of type DateTimeImmutable, DateTime given, called in vendor/php-task/php-task/src/Task/Scheduler/TaskScheduler.php on line 110 on every PHP version. Per @alexander-schranz' review, the conversion belongs on the caller side rather than in every TaskExecutionRepository implementation — that's this PR.
The other fixes are needed so the test suite here actually runs and stays green; they were never caught because the ubuntu-20.04 runner is unavailable, which is being addressed separately.