【发布时间】:2015-11-03 16:06:02
【问题描述】:
当我尝试将作业推送到我的 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 的事实有关?当我尝试使用序列化模型时,我只是得到一个未定义的属性 $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 作业执行良好
【问题讨论】:
-
为什么不发布导致错误的代码?你怎么称呼这份工作? $目录设置了吗?为什么返回 true?
-
从错误看来,它发生在您排队作业时,请发布一些 sn-p 您如何排队作业。
-
感谢您的帮助,我已经更新了我的问题。也不知道我为什么要回归真实,认为那是一个意外
-
@ExoticChimp 你解决了这个问题吗?我有类似的问题,你会在这里贡献stackoverflow.com/questions/33917028/…
-
你有运气吗?我也面临同样的问题。
标签: php laravel laravel-5 message-queue beanstalkd