peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
811 stars 144 forks source link

Jobs that call the same PHP files, but with different parameters, have the same job ID generated, based only on the name of the script. #95

Closed phinor closed 4 years ago

phinor commented 5 years ago

Environment

How to reproduce

$scheduler = new \GO\Scheduler();
$scheduler->php("backup.php", null, ['--type' => 'monthly'])->monthly();
$scheduler->php("backup.php", null, ['--type' => 'weekly'])->weekly();
$scheduler->php("backup.php", null, ['--type' => 'daily'])->daily();
$jobs = $scheduler->getQueuedJobs ();
/** @var \GO\Job $job */
foreach ($jobs as $job)
{
    echo $job->getId()."<br>";
}

Expected Behaviour

Each job gets its own unique ID, differentiated by the parameters.

Observed Behaviour

The three jobs share the same ID.

Possible Solutions

The Job ID is created using a hash that takes into account the first two parameters that are passed to the \GO\Job constructor (i.e. $command and $args), while allowing the ID to be overridden by the supplied identifier, if any.

peppeocchi commented 4 years ago

@phinor thank you for the PR, it's now merged so I'll close this issue