Closed
Description
- Laravel-mongodb Version: v3.8.1
- PHP Version: 7.4.9
- Laravel Version: v8.15.0
- Database Driver & Version: jenssegers/mongodb v3.8.1
Description:
Trying to get property 'id' of non-object
on vendor/laravel/framework/src/Illuminate/Bus/DatabaseBatchRepository.php:256
Steps to reproduce
- Just create the Bus like:
use App\Jobs\ProcessPodcast;
use App\Podcast;
use Illuminate\Bus\Batch;
use Illuminate\Support\Facades\Bus;
use Throwable;
$batch = Bus::batch([
new ProcessPodcast(Podcast::find(1)),
new ProcessPodcast(Podcast::find(2)),
new ProcessPodcast(Podcast::find(3)),
new ProcessPodcast(Podcast::find(4)),
new ProcessPodcast(Podcast::find(5)),
])->then(function (Batch $batch) {
// All jobs completed successfully...
})->catch(function (Batch $batch, Throwable $e) {
// First batch job failure detected...
})->finally(function (Batch $batch) {
// The batch has finished executing...
})->dispatch();
Expected behaviour
in Illuminate\Bus\DatabaseBatchRepository::find
$batch = $this->connection->table($this->table)
->where('id', $batchId)
->first();
// $batch should be a object instead of array
if ($batch) {
// the error is trigger by this method "toBatch"
return $this->toBatch($batch);
}
protected function toBatch($batch)
{
return $this->factory->make(
$this,
$batch->id, // this $batch is a array and not a object
$batch->name,
(int) $batch->total_jobs,
(int) $batch->pending_jobs,
(int) $batch->failed_jobs,
json_decode($batch->failed_job_ids, true),
unserialize($batch->options),
CarbonImmutable::createFromTimestamp($batch->created_at),
$batch->cancelled_at ? CarbonImmutable::createFromTimestamp($batch->cancelled_at) : $batch->cancelled_at,
$batch->finished_at ? CarbonImmutable::createFromTimestamp($batch->finished_at) : $batch->finished_at
);
}
Actual behaviour
in Illuminate\Bus\DatabaseBatchRepository::find
$batch = $this->connection->table($this->table)
->where('id', $batchId)
->first();
// it returns a array and not a object
Thanks