Skip to content

Unique jobs broken when using uniqueVia method #54293

@DougSisk

Description

@DougSisk

Laravel Version

11.39.0

PHP Version

8.4.2

Database Driver & Version

No response

Description

This deals specifically with PR #54000.

This line broke my unit tests due to fact that uniqueVia() returns a Illuminate\Contracts\Cache\Repository contract. getName() is only on Illuminate\Cache\Repository, not the individual drivers.

Steps To Reproduce

Create a queue job class that implements ShouldBeUnique with a uniqueVia method that returns a Cache driver:

<?php

namespace App\Jobs;

use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Cache;

class TestJob implements ShouldBeUnique, ShouldQueue
{
    use Queueable;

    public function handle(): void
    {
        //
    }

    public function uniqueVia(): Repository
    {
        return Cache::driver('array');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions