当我尝试将作业推到我的Laravel队列时,我反复收到以下错误:
Argument 1 passed to Illuminate\Queue\Jobs\Job::resolveAndFire() must be of the type array, null given, called in /home/vagrant/Code/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php on line 53 and defined
我不知道出了什么问题,但我猜想这可能与我没有使用SerializesModel Trait有关。当我尝试使用Serializes model时,我只得到了一个未定义的属性$directory错误。
作业类是:
/**
* Class StoreFile
* @package App\Jobs
*/
class StoreFile extends Job implements SelfHandling, ShouldQueue
{
use InteractsWithQueue;
/**
* @param string $directory
* @param string $filename
* @param UploadedFile $file
*/
public function __construct($directory, $filename, $file)
{
$this->directory = $directory;
$this->filename = $filename;
$this->file = $file;
}
/**
* @param FileSystem $storage
* @return boolean
*/
public function handle(FileSystem $storage)
{
$path = $this->directory . $this->filename;
$storage->disk('s3')->put($path, $this->file);
return true;
}
}
更新 我使用以下方式从另一个类中排队作业:
$this->dispatch(new StoreFile($directory, rawurlencode($filename), file_get_contents($evidence)));
当 $evidence 是一个 UploadedFile 时。我确信如果我移除 ShouldQueue/InteractsWithQueue,所有变量都被设置正确,任务可以正常执行。
json_decoded
时意外地导致了“空字符串”,令人惊讶的是,这意味着原始数据不是有效的json,这引发了一个问题,beanstalk首先如何接受它,或者laravel如何添加它!! - Ahmad Hajjar