throw an exception when trying to push a background job that wont fit in the table

otherwise it will lead to failures in json decode and unexpected and hard to debug issues when running the job
This commit is contained in:
Robin Appelman 2015-02-17 16:52:09 +01:00
parent 6fc0eb0236
commit c2a7fff4f6

View file

@ -57,6 +57,9 @@ class JobList implements IJobList {
$class = $job;
}
$argument = json_encode($argument);
if (strlen($argument) > 2048) {
throw new \InvalidArgumentException('Background job arguments cant exceed 2048 characters (json encoded');
}
$query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)');
$query->execute(array($class, $argument));
}