Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 24, 2020
2 parents c6bd59a + 06a21a2 commit 09852c9
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Release Notes for 6.x

## [Unreleased](https://github.com/laravel/framework/compare/v6.20.7...6.x)
## [Unreleased](https://github.com/laravel/framework/compare/v6.20.8...6.x)


## [v6.20.8 (2020-12-22)](https://github.com/laravel/framework/compare/v6.20.7...v6.20.8)

### Fixed
- Fixed `Illuminate\Validation\Concerns\ValidatesAttributes::validateJson()` for PHP8 ([#35646](https://github.com/laravel/framework/pull/35646))
- Catch DecryptException with invalid X-XSRF-TOKEN in `Illuminate\Foundation\Http\Middleware\VerifyCsrfToken` ([#35671](https://github.com/laravel/framework/pull/35671))


## [v6.20.7 (2020-12-08)](https://github.com/laravel/framework/compare/v6.20.6...v6.20.7)
Expand Down
27 changes: 26 additions & 1 deletion CHANGELOG-8.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Release Notes for 8.x

## [Unreleased](https://github.com/laravel/framework/compare/v8.19.0...8.x)
## [Unreleased](https://github.com/laravel/framework/compare/v8.20.1...8.x)


## [v8.20.1 (2020-12-22)](https://github.com/laravel/framework/compare/v8.20.0...v8.20.1)

### Revert
- Revert [Clear a cached user in RequestGuard if a request is changed](https://github.com/laravel/framework/pull/35692) ([ca8ccd6](https://github.com/laravel/framework/commit/ca8ccd6757d5639f0e5fb241b3df6878da6ce34e))


## [v8.20.0 (2020-12-22)](https://github.com/laravel/framework/compare/v8.19.0...v8.20.0)

### Added
- Added `Illuminate\Database\DBAL\TimestampType` ([a5761d4](https://github.com/laravel/framework/commit/a5761d4187abea654cb422c2f70054a880ffd2e0), [cff3705](https://github.com/laravel/framework/commit/cff37055cbf031109ae769e8fd6ad1951be47aa6) [382445f](https://github.com/laravel/framework/commit/382445f8487de45a05ebe121837f917b92560a97), [810047e](https://github.com/laravel/framework/commit/810047e1f184f8a4def372885591e4fbb6996b51))
- Added ability to specify a separate lock connection ([#35621](https://github.com/laravel/framework/pull/35621), [3d95235](https://github.com/laravel/framework/commit/3d95235a6ad8525886071ad68e818a225786064f))
- Added `Illuminate\Database\Eloquent\Relations\Concerns\InteractsWithPivotTable::syncWithPivotValues()` ([#35644](https://github.com/laravel/framework/pull/35644), [49b3ce0](https://github.com/laravel/framework/commit/49b3ce098d8a612797b195c4e3774b1e00c604c8))

### Fixed
- Fixed `Illuminate\Validation\Concerns\ValidatesAttributes::validateJson()` for PHP8 ([#35646](https://github.com/laravel/framework/pull/35646))
- Fixed `assertCookieExpired()` and `assertCookieNotExpired()` methods in `Illuminate\Testing\TestResponse` ([#35637](https://github.com/laravel/framework/pull/35637))
- Fixed: Account for a numerical array of views in Mailable::renderForAssertions() ([#35662](https://github.com/laravel/framework/pull/35662))
- Catch DecryptException with invalid X-XSRF-TOKEN in `Illuminate\Foundation\Http\Middleware\VerifyCsrfToken` ([#35671](https://github.com/laravel/framework/pull/35671))

### Changed
- Check configuration in `Illuminate\Foundation\Console\Kernel::scheduleCache()` ([a253d0e](https://github.com/laravel/framework/commit/a253d0e40d3deb293d54df9f4455879af5365aab))
- Modify `Model::mergeCasts` to return `$this` ([#35683](https://github.com/laravel/framework/pull/35683))
- Clear a cached user in RequestGuard if a request is changed ([#35692](https://github.com/laravel/framework/pull/35692))


## [v8.19.0 (2020-12-15)](https://github.com/laravel/framework/compare/v8.18.1...v8.19.0)
Expand Down
2 changes: 0 additions & 2 deletions src/Illuminate/Auth/RequestGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public function setRequest(Request $request)
{
$this->request = $request;

$this->user = null;

return $this;
}
}
26 changes: 25 additions & 1 deletion src/Illuminate/Bus/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Carbon\CarbonImmutable;
use Closure;
use DateTimeInterface;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Str;

class DatabaseBatchRepository implements BatchRepository
class DatabaseBatchRepository implements PrunableBatchRepository
{
/**
* The batch factory instance.
Expand Down Expand Up @@ -230,6 +231,29 @@ public function delete(string $batchId)
$this->connection->table($this->table)->where('id', $batchId)->delete();
}

/**
* Prune all of the entries older than the given date.
*
* @param \DateTimeInterface $before
* @return int
*/
public function prune(DateTimeInterface $before)
{
$query = $this->connection->table($this->table)
->whereNotNull('finished_at')
->where('finished_at', '<', $before->getTimestamp());

$totalDeleted = 0;

do {
$deleted = $query->take(1000)->delete();

$totalDeleted += $deleted;
} while ($deleted !== 0);

return $totalDeleted;
}

/**
* Execute the given Closure within a storage specific transaction.
*
Expand Down
16 changes: 16 additions & 0 deletions src/Illuminate/Bus/PrunableBatchRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Illuminate\Bus;

use DateTimeInterface;

interface PrunableBatchRepository extends BatchRepository
{
/**
* Prune all of the entries older than the given date.
*
* @param \DateTimeInterface $before
* @return int
*/
public function prune(DateTimeInterface $before);
}
4 changes: 3 additions & 1 deletion src/Illuminate/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ protected function registerDoctrineTypes()
$types = $this->app['config']->get('database.dbal.types', []);

foreach ($types as $name => $class) {
Type::addType($name, $class);
if (! Type::hasType($name)) {
Type::addType($name, $class);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function __construct(Application $app)
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next)
{
Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand;
use Illuminate\Queue\Console\ListenCommand as QueueListenCommand;
use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand;
use Illuminate\Queue\Console\PruneBatchesCommand as QueuePruneBatchesCommand;
use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand;
use Illuminate\Queue\Console\RetryBatchCommand as QueueRetryBatchCommand;
use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand;
Expand Down Expand Up @@ -108,6 +109,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid
'QueueFlush' => FlushFailedQueueCommand::class,
'QueueForget' => ForgetFailedQueueCommand::class,
'QueueListen' => QueueListenCommand::class,
'QueuePruneBatches' => QueuePruneBatchesCommand::class,
'QueueRestart' => QueueRestartCommand::class,
'QueueRetry' => QueueRetryCommand::class,
'QueueRetryBatch' => QueueRetryBatchCommand::class,
Expand Down Expand Up @@ -656,6 +658,18 @@ protected function registerQueueListenCommand()
});
}

/**
* Register the command.
*
* @return void
*/
protected function registerQueuePruneBatchesCommand()
{
$this->app->singleton(QueuePruneBatchesCommand::class, function () {
return new QueuePruneBatchesCommand;
});
}

/**
* Register the command.
*
Expand Down
52 changes: 52 additions & 0 deletions src/Illuminate/Queue/Console/PruneBatchesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Illuminate\Queue\Console;

use Carbon\Carbon;
use Illuminate\Bus\BatchRepository;
use Illuminate\Bus\Prunable;
use Illuminate\Console\Command;

class PruneBatchesCommand extends Command
{
/**
* The console command signature.
*
* @var string
*/
protected $signature = 'queue:prune-batches {--hours=24 : The number of hours to retain batch data}';

/**
* The name of the console command.
*
* This name is used to identify the command during lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'queue:prune-batches';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Prune stale entries from the batches database';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$count = 0;

$repository = $this->laravel[BatchRepository::class];

if ($repository instanceof Prunable) {
$count = $repository->prune(Carbon::now()->subHours($this->option('hours')));
}

$this->info("{$count} entries deleted!");
}
}

0 comments on commit 09852c9

Please sign in to comment.