Skip to content
Closed
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
86 changes: 43 additions & 43 deletions .github/workflows/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,49 +132,49 @@ jobs:
DB_CONNECTION: mysql
DB_USERNAME: root

# pgsql:
# runs-on: ubuntu-20.04

# services:
# postgresql:
# image: postgres:14
# env:
# POSTGRES_DB: forge
# POSTGRES_USER: forge
# POSTGRES_PASSWORD: password
# ports:
# - 5432:5432
# options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3

# strategy:
# fail-fast: true

# name: PostgreSQL 14

# steps:
# - name: Checkout code
# uses: actions/checkout@v2

# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: 8.1
# extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql
# tools: composer:v2
# coverage: none

# - name: Install dependencies
# uses: nick-invision/retry@v1
# with:
# timeout_minutes: 5
# max_attempts: 5
# command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

# - name: Execute tests
# run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group MySQL
# env:
# DB_CONNECTION: pgsql
# DB_PASSWORD: password
pgsql:
runs-on: ubuntu-20.04

services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: forge
POSTGRES_USER: forge
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: true

name: PostgreSQL 14

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Database --verbose --exclude-group MySQL
env:
DB_CONNECTION: pgsql
DB_PASSWORD: password

mssql:
runs-on: ubuntu-20.04
Expand Down
45 changes: 36 additions & 9 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Illuminate\Support\Traits\ReflectsClosures;
use Psr\Http\Client\ClientExceptionInterface;
use Symfony\Component\Process\Process;
use Throwable;

class Event
{
Expand Down Expand Up @@ -218,11 +219,17 @@ public function mutexName()
*/
protected function runCommandInForeground(Container $container)
{
$this->callBeforeCallbacks($container);
try {
$this->callBeforeCallbacks($container);

$this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
$this->exitCode = Process::fromShellCommandline(
$this->buildCommand(), base_path(), null, null, null
)->run();

$this->callAfterCallbacks($container);
$this->callAfterCallbacks($container);
} finally {
$this->removeMutex();
}
}

/**
Expand All @@ -233,9 +240,15 @@ protected function runCommandInForeground(Container $container)
*/
protected function runCommandInBackground(Container $container)
{
$this->callBeforeCallbacks($container);
try {
$this->callBeforeCallbacks($container);

Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
} catch (Throwable $exception) {
$this->removeMutex();

Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
throw $exception;
}
}

/**
Expand Down Expand Up @@ -275,7 +288,11 @@ public function callAfterCallbacksWithExitCode(Container $container, $exitCode)
{
$this->exitCode = (int) $exitCode;

$this->callAfterCallbacks($container);
try {
$this->callAfterCallbacks($container);
} finally {
$this->removeMutex();
}
}

/**
Expand Down Expand Up @@ -647,9 +664,7 @@ public function withoutOverlapping($expiresAt = 1440)

$this->expiresAt = $expiresAt;

return $this->then(function () {
$this->mutex->forget($this);
})->skip(function () {
return $this->skip(function () {
return $this->mutex->exists($this);
});
}
Expand Down Expand Up @@ -915,4 +930,16 @@ public function preventOverlapsUsing(EventMutex $mutex)

return $this;
}

/**
* Delete the mutex for the event.
*
* @return void
*/
protected function removeMutex()
{
if ($this->withoutOverlapping) {
$this->mutex->forget($this);
}
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/PostgresBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ protected function parseSearchPath($searchPath)
$searchPath = $matches[0];
}

array_walk($searchPath, function (&$schema) {
array_walk($searchPath ?? [], function (&$schema) {
$schema = trim($schema, '\'"');

$schema = $schema === '$user'
? $this->connection->getConfig('username')
: $schema;
});

return $searchPath;
return $searchPath ?? [];
}
}
20 changes: 19 additions & 1 deletion src/Illuminate/Queue/SqsQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,28 @@ public function getQueue($queue)
$queue = $queue ?: $this->default;

return filter_var($queue, FILTER_VALIDATE_URL) === false
? rtrim($this->prefix, '/').'/'.Str::finish($queue, $this->suffix)
? $this->suffixQueue($queue, $this->suffix)
: $queue;
}

/**
* Add the given suffix to the given queue name.
*
* @param string $queue
* @param string $suffix
* @return string
*/
protected function suffixQueue($queue, $suffix = '')
{
if (Str::endsWith($queue, '.fifo')) {
$queue = Str::beforeLast($queue, '.fifo');

return rtrim($this->prefix, '/').'/'.Str::finish($queue, $suffix).'.fifo';
}

return rtrim($this->prefix, '/').'/'.Str::finish($queue, $this->suffix);
}

/**
* Get the underlying SQS instance.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/Engines/EngineResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EngineResolver
*/
public function register($engine, Closure $resolver)
{
unset($this->resolved[$engine]);
$this->forget($engine);

$this->resolvers[$engine] = $resolver;
}
Expand Down
37 changes: 37 additions & 0 deletions tests/Queue/QueueSqsQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ public function testGetQueueProperlyResolvesUrlWithPrefix()
$this->assertEquals($queueUrl, $queue->getQueue('test'));
}

public function testGetQueueProperlyResolvesFifoUrlWithPrefix()
{
$this->queueName = 'emails.fifo';
$this->queueUrl = $this->prefix.$this->queueName;
$queue = new SqsQueue($this->sqs, $this->queueName, $this->prefix);
$this->assertEquals($this->queueUrl, $queue->getQueue(null));
$queueUrl = $this->baseUrl.'/'.$this->account.'/test.fifo';
$this->assertEquals($queueUrl, $queue->getQueue('test.fifo'));
}

public function testGetQueueProperlyResolvesUrlWithoutPrefix()
{
$queue = new SqsQueue($this->sqs, $this->queueUrl);
Expand All @@ -152,6 +162,16 @@ public function testGetQueueProperlyResolvesUrlWithoutPrefix()
$this->assertEquals($queueUrl, $queue->getQueue($queueUrl));
}

public function testGetQueueProperlyResolvesFifoUrlWithoutPrefix()
{
$this->queueName = 'emails.fifo';
$this->queueUrl = $this->prefix.$this->queueName;
$queue = new SqsQueue($this->sqs, $this->queueUrl);
$this->assertEquals($this->queueUrl, $queue->getQueue(null));
$fifoQueueUrl = $this->baseUrl.'/'.$this->account.'/test.fifo';
$this->assertEquals($fifoQueueUrl, $queue->getQueue($fifoQueueUrl));
}

public function testGetQueueProperlyResolvesUrlWithSuffix()
{
$queue = new SqsQueue($this->sqs, $this->queueName, $this->prefix, $suffix = '-staging');
Expand All @@ -160,11 +180,28 @@ public function testGetQueueProperlyResolvesUrlWithSuffix()
$this->assertEquals($queueUrl, $queue->getQueue('test'));
}

public function testGetQueueProperlyResolvesFifoUrlWithSuffix()
{
$this->queueName = 'emails.fifo';
$queue = new SqsQueue($this->sqs, $this->queueName, $this->prefix, $suffix = '-staging');
$this->assertEquals("{$this->prefix}emails-staging.fifo", $queue->getQueue(null));
$queueUrl = $this->baseUrl.'/'.$this->account.'/test'.$suffix.'.fifo';
$this->assertEquals($queueUrl, $queue->getQueue('test.fifo'));
}

public function testGetQueueEnsuresTheQueueIsOnlySuffixedOnce()
{
$queue = new SqsQueue($this->sqs, "{$this->queueName}-staging", $this->prefix, $suffix = '-staging');
$this->assertEquals($this->queueUrl.$suffix, $queue->getQueue(null));
$queueUrl = $this->baseUrl.'/'.$this->account.'/test'.$suffix;
$this->assertEquals($queueUrl, $queue->getQueue('test-staging'));
}

public function testGetFifoQueueEnsuresTheQueueIsOnlySuffixedOnce()
{
$queue = new SqsQueue($this->sqs, "{$this->queueName}-staging.fifo", $this->prefix, $suffix = '-staging');
$this->assertEquals("{$this->prefix}{$this->queueName}{$suffix}.fifo", $queue->getQueue(null));
$queueUrl = $this->baseUrl.'/'.$this->account.'/test'.$suffix.'.fifo';
$this->assertEquals($queueUrl, $queue->getQueue('test-staging.fifo'));
}
}