Fix: pass RunTemplate object instead of int to prepareJob()#27
Conversation
The schedule action was passing $rt->getMyKey() (int) to Job::prepareJob() which expects a RunTemplate object as its first argument. Co-Authored-By: Oz <oz-agent@warp.dev>
📝 WalkthroughWalkthroughThe RunTemplate scheduling path modified to pass the complete RunTemplate object to Job::prepareJob instead of only its key identifier. A descriptive docblock was added to the execute method for documentation clarity. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @Vitexus. The following files were modified: * `src/Command/RunTemplateCommand.php`
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Command/RunTemplateCommand.php`:
- Around line 577-578: The assignment to $prepared is unused — call prepareJob
with the RunTemplate ($rt) and other args without assigning its return value;
remove the unused $prepared variable and keep the existing call to
$jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor,
$scheduleType) (note: scheduleJobRun() is invoked inside prepareJob()).
| $prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType); | ||
| // scheduleJobRun() is now called automatically inside prepareJob() |
There was a problem hiding this comment.
Correct fix, but remove unused variable assignment.
The fix correctly passes the RunTemplate object instead of its integer key, resolving the TypeError. However, the $prepared variable is assigned but never used.
🧹 Proposed fix to remove unused variable
- $prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);
+ $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $prepared = $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType); | |
| // scheduleJobRun() is now called automatically inside prepareJob() | |
| $jobber->prepareJob($rt, $overridedEnv, $scheduleDateTime, $executor, $scheduleType); | |
| // scheduleJobRun() is now called automatically inside prepareJob() |
🧰 Tools
🪛 PHPMD (2.15.0)
[warning] 577-577: Avoid unused local variables such as '$prepared'. (undefined)
(UnusedLocalVariable)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Command/RunTemplateCommand.php` around lines 577 - 578, The assignment to
$prepared is unused — call prepareJob with the RunTemplate ($rt) and other args
without assigning its return value; remove the unused $prepared variable and
keep the existing call to $jobber->prepareJob($rt, $overridedEnv,
$scheduleDateTime, $executor, $scheduleType) (note: scheduleJobRun() is invoked
inside prepareJob()).
The
runtemplate scheduleaction was passing$rt->getMyKey()(int) toJob::prepareJob()which expects aRunTemplateobject as its first argument, causing a PHP Fatal TypeError on every schedule attempt.Summary by CodeRabbit
Refactor
Chores