Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/8.x' into 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlindaruk committed Jul 26, 2022
2 parents d7b41f4 + bdc707f commit 3415bac
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function retrieveById($identifier)
$model = $this->createModel();

return $this->newModelQuery($model)
->where($model->qualifyColumn($model->getAuthIdentifierName()), $identifier)
->where($model->getAuthIdentifierName(), $identifier)
->first();
}

Expand All @@ -65,7 +65,7 @@ public function retrieveByToken($identifier, $token)
$model = $this->createModel();

$retrievedModel = $this->newModelQuery($model)->where(
$model->qualifyColumn($model->getAuthIdentifierName()), $identifier
$model->getAuthIdentifierName(), $identifier
)->first();

if (! $retrievedModel) {
Expand Down
8 changes: 5 additions & 3 deletions src/Illuminate/Cache/DynamoDbLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public function __construct(DynamoDbStore $dynamo, $name, $seconds, $owner = nul
*/
public function acquire()
{
return $this->dynamo->add(
$this->name, $this->owner, $this->seconds
);
if ($this->seconds > 0) {
return $this->dynamo->add($this->name, $this->owner, $this->seconds);
} else {
return $this->dynamo->add($this->name, $this->owner, 86400);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '8.83.20';
const VERSION = '8.83.23';

/**
* The base path for the Laravel installation.
Expand Down
20 changes: 3 additions & 17 deletions src/Illuminate/Queue/SyncQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

class SyncQueue extends Queue implements QueueContract
{
protected $jobsCount = 0;

/**
* Get the size of the queue.
*
Expand All @@ -39,8 +37,6 @@ public function push($job, $data = '', $queue = null)
{
$queueJob = $this->resolveJob($this->createPayload($job, $queue, $data), $queue);

$this->jobsCount++;

try {
$this->raiseBeforeJobEvent($queueJob);

Expand All @@ -49,8 +45,6 @@ public function push($job, $data = '', $queue = null)
$this->raiseAfterJobEvent($queueJob);
} catch (Throwable $e) {
$this->handleException($queueJob, $e);
} finally {
$this->jobsCount--;
}

return 0;
Expand Down Expand Up @@ -119,19 +113,11 @@ protected function raiseExceptionOccurredJobEvent(Job $job, Throwable $e)
*/
protected function handleException(Job $queueJob, Throwable $e)
{
static $isGuarded = false;

if ($isGuarded) {
$isGuarded = false;
} else {
$isGuarded = $this->jobsCount > 1;
$this->raiseExceptionOccurredJobEvent($queueJob, $e);

$this->raiseExceptionOccurredJobEvent($queueJob, $e);
$queueJob->fail($e);

$queueJob->fail($e);

throw $e;
}
throw $e;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions tests/Auth/AuthEloquentUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function testRetrieveByIDReturnsUser()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn('bar');
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveById(1);
Expand All @@ -40,8 +39,7 @@ public function testRetrieveByTokenReturnsUser()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn($mockUser);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand All @@ -55,8 +53,7 @@ public function testRetrieveTokenWithBadIdentifierReturnsNull()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn(null);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand All @@ -81,8 +78,7 @@ public function testRetrieveByBadTokenReturnsNull()
$mock = m::mock(stdClass::class);
$mock->shouldReceive('newQuery')->once()->andReturn($mock);
$mock->shouldReceive('getAuthIdentifierName')->once()->andReturn('id');
$mock->shouldReceive('qualifyColumn')->with('id')->andReturn('users.id');
$mock->shouldReceive('where')->once()->with('users.id', 1)->andReturn($mock);
$mock->shouldReceive('where')->once()->with('id', 1)->andReturn($mock);
$mock->shouldReceive('first')->once()->andReturn($mockUser);
$provider->expects($this->once())->method('createModel')->willReturn($mock);
$user = $provider->retrieveByToken(1, 'a');
Expand Down
54 changes: 4 additions & 50 deletions tests/Integration/Queue/JobChainingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class JobChainingTest extends TestCase
{
public static $catchCallbackCount = 0;
public static $catchCallbackRan = false;

protected function getEnvironmentSetUp($app)
{
Expand All @@ -30,6 +30,7 @@ protected function tearDown(): void
JobChainingTestFirstJob::$ran = false;
JobChainingTestSecondJob::$ran = false;
JobChainingTestThirdJob::$ran = false;
static::$catchCallbackRan = false;
}

public function testJobsCanBeChainedOnSuccess()
Expand Down Expand Up @@ -147,56 +148,19 @@ public function testThirdJobIsNotFiredIfSecondFails()

public function testCatchCallbackIsCalledOnFailure()
{
self::$catchCallbackCount = 0;

Bus::chain([
new JobChainingTestFirstJob,
new JobChainingTestFailingJob,
new JobChainingTestSecondJob,
])->catch(static function () {
self::$catchCallbackCount++;
self::$catchCallbackRan = true;
})->dispatch();

$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertTrue(static::$catchCallbackRan);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}

public function testCatchCallbackIsCalledOnceOnSyncQueue()
{
self::$catchCallbackCount = 0;

try {
Bus::chain([
new JobChainingTestFirstJob(),
new JobChainingTestThrowJob(),
new JobChainingTestSecondJob(),
])->catch(function () {
self::$catchCallbackCount++;
})->onConnection('sync')->dispatch();
} finally {
$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}

self::$catchCallbackCount = 0;

try {
Bus::chain([
new JobChainingTestFirstJob(),
new JobChainingTestThrowJob(),
new JobChainingTestSecondJob(),
])->catch(function () {
self::$catchCallbackCount++;
})->onConnection('sync')->dispatch();
} finally {
$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertSame(1, static::$catchCallbackCount);
$this->assertFalse(JobChainingTestSecondJob::$ran);
}
}

public function testChainJobsUseSameConfig()
{
JobChainingTestFirstJob::dispatch()->allOnQueue('some_queue')->allOnConnection('sync1')->chain([
Expand Down Expand Up @@ -329,13 +293,3 @@ public function handle()
$this->fail();
}
}

class JobChainingTestThrowJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;

public function handle()
{
throw new \Exception();
}
}

0 comments on commit 3415bac

Please sign in to comment.