Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix unique jobs that have a uniqueVia method #54294

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ protected function getSeconds($ttl)
*
* @return string|null
*/
protected function getName()
public function getName()
{
return $this->config['store'] ?? null;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Integration/Queue/UniqueJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Container\Container;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
Expand Down Expand Up @@ -51,6 +52,14 @@ public function testUniqueJobsAreNotDispatched()
);
}

public function testUniqueJobWithViaDispatched()
{
Bus::fake();

UniqueViaJob::dispatch();
Bus::assertDispatched(UniqueViaJob::class);
}

public function testLockIsReleasedForSuccessfulJobs()
{
UniqueTestJob::$handled = false;
Expand Down Expand Up @@ -222,3 +231,11 @@ public function __construct(public User $user)
{
}
}

class UniqueViaJob extends UniqueTestJob
{
public function uniqueVia(): Cache
{
return Container::getInstance()->make(Cache::class);
}
}