3

I repeatedly receive the following error when I try to push a job onto my Laravel Queue:

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

I have no clue what is going wrong but I'm guessing it's something to do with the fact I haven't used the SerializesModel Trait? When I try to use Serializes model, I just get an undefined property $directory error.

The job class is:

/**
 * 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;
    }
}

UPDATE I queue the job from another class using this:

$this->dispatch(new StoreFile($directory, rawurlencode($filename), file_get_contents($evidence)));

Where $evidence is an UploadedFile. I'm certain that all the variables are set as if I remove the ShouldQueue/InteractsWithQueue the job executes fine

ExoticChimp
  • 1,884
  • 1
  • 19
  • 37
  • Why don't you post the code leading to the error? How do you call the job? Is $directory set? why do you return true? – baao Aug 11 '15 at 12:59
  • from the error looks like it happens when you queue the job, please post some snippet how you queue the job. – yangqi Aug 11 '15 at 15:15
  • Thanks for the help, I've updated my question. Also no idea why I'm returning true, think that was an accident – ExoticChimp Aug 11 '15 at 18:03
  • @ExoticChimp did you solved the issue ? I have the similar question , would you contribute on it here http://stackoverflow.com/questions/33917028/undefined-property-illuminate-queue-jobs-beanstalkdjob-name – ikuchris Nov 25 '15 at 12:58
  • did you have any luck with that? I am facing the same problem. – Ahmad Hajjar Aug 26 '16 at 11:18
  • @yangqi On my side this happens when the Worker.php tries to execute the job, under debug I found that the job raw data is surprisingly resulting in `empty string` when it is `json_decoded`, surprising because this means that the raw data is not valid json, which raises the question, how did beanstalk accepted it in the first place, or how laravel added it !! – Ahmad Hajjar Aug 26 '16 at 11:21

2 Answers2

0

In my case, it was because the jobs tables was having a payload "0" instead of JSON for executing the job.

Martin Tonev
  • 747
  • 12
  • 21
-4

The error can be solved easy. Check: may be you added manualy test message to queue. So, this message can broke your code, because has another structure.

org
  • 1
  • 5