From 3b87b6f972de4445bed7458c810671f2bbc861cb Mon Sep 17 00:00:00 2001 From: dmason30 Date: Tue, 22 Dec 2020 15:11:18 +0000 Subject: [PATCH 01/34] Add command to clean batches table --- src/Illuminate/Bus/BatchRepository.php | 8 ++++ .../Bus/DatabaseBatchRepository.php | 22 ++++++++++ .../Providers/ArtisanServiceProvider.php | 14 +++++++ .../Queue/Console/FlushBatchCommand.php | 40 +++++++++++++++++++ .../Testing/Fakes/BatchRepositoryFake.php | 12 ++++++ 5 files changed, 96 insertions(+) create mode 100644 src/Illuminate/Queue/Console/FlushBatchCommand.php diff --git a/src/Illuminate/Bus/BatchRepository.php b/src/Illuminate/Bus/BatchRepository.php index 098ccef20ed6..978da8204843 100644 --- a/src/Illuminate/Bus/BatchRepository.php +++ b/src/Illuminate/Bus/BatchRepository.php @@ -89,4 +89,12 @@ public function delete(string $batchId); * @return mixed */ public function transaction(Closure $callback); + + /** + * Prune all of the entries older than the given date. + * + * @param \DateTimeInterface $before + * @return int + */ + public function prune(\DateTimeInterface $before); } diff --git a/src/Illuminate/Bus/DatabaseBatchRepository.php b/src/Illuminate/Bus/DatabaseBatchRepository.php index d911c380d551..a1efdb459654 100644 --- a/src/Illuminate/Bus/DatabaseBatchRepository.php +++ b/src/Illuminate/Bus/DatabaseBatchRepository.php @@ -243,6 +243,28 @@ public function transaction(Closure $callback) }); } + /** + * 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) + ->where('finished_at', '<', $before); + + $totalDeleted = 0; + + do { + $deleted = $query->take(1000)->delete(); + + $totalDeleted += $deleted; + } while ($deleted !== 0); + + return $totalDeleted; + } + /** * Convert the given raw batch to a Batch object. * diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 9cce44c00e3f..ec4d7a0ca64b 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -64,6 +64,7 @@ use Illuminate\Queue\Console\ClearCommand as QueueClearCommand; use Illuminate\Queue\Console\FailedTableCommand; use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand; +use Illuminate\Queue\Console\FlushBatchCommand as FlushBatchQueueCommand; use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Queue\Console\ListenCommand as QueueListenCommand; use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; @@ -105,6 +106,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'QueueClear' => 'command.queue.clear', 'QueueFailed' => 'command.queue.failed', 'QueueFlush' => 'command.queue.flush', + 'QueueFlushBatch' => 'command.queue.flush-batch', 'QueueForget' => 'command.queue.forget', 'QueueListen' => 'command.queue.listen', 'QueueRestart' => 'command.queue.restart', @@ -672,6 +674,18 @@ protected function registerQueueFlushCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerQueueFlushBatchCommand() + { + $this->app->singleton('command.queue.flush-batch', function () { + return new FlushBatchQueueCommand; + }); + } + /** * Register the command. * diff --git a/src/Illuminate/Queue/Console/FlushBatchCommand.php b/src/Illuminate/Queue/Console/FlushBatchCommand.php new file mode 100644 index 000000000000..edfefb03fb1f --- /dev/null +++ b/src/Illuminate/Queue/Console/FlushBatchCommand.php @@ -0,0 +1,40 @@ +option('hours'); + + $before = Carbon::now()->subHours($hours); + + $count = $this->laravel[BatchRepository::class]->prune($before); + + $this->info("{$count} entries deleted successfully."); + } +} diff --git a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php index 55681f4d5534..c3533fa2ea2e 100644 --- a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php @@ -8,6 +8,7 @@ use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Bus\UpdatedBatchJobCounts; +use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\Facade; use Illuminate\Support\Str; @@ -134,4 +135,15 @@ public function transaction(Closure $callback) { return $callback(); } + + /** + * Prune all of the entries older than the given date. + * + * @param \DateTimeInterface $before + * @return int + */ + public function prune(\DateTimeInterface $before) + { + return 0; + } } From a41160515d626f5957129db8ed0c3a5601567dad Mon Sep 17 00:00:00 2001 From: dmason30 Date: Tue, 22 Dec 2020 15:33:14 +0000 Subject: [PATCH 02/34] use timestamp --- src/Illuminate/Bus/DatabaseBatchRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Bus/DatabaseBatchRepository.php b/src/Illuminate/Bus/DatabaseBatchRepository.php index a1efdb459654..cc56ead8d649 100644 --- a/src/Illuminate/Bus/DatabaseBatchRepository.php +++ b/src/Illuminate/Bus/DatabaseBatchRepository.php @@ -252,7 +252,7 @@ public function transaction(Closure $callback) public function prune(\DateTimeInterface $before) { $query = $this->connection->table($this->table) - ->where('finished_at', '<', $before); + ->where('finished_at', '<', $before->getTimestamp()); $totalDeleted = 0; From ee8c0b5abe54a892fb51df1a9ea8337d6d5851d4 Mon Sep 17 00:00:00 2001 From: dmason30 Date: Tue, 22 Dec 2020 15:44:51 +0000 Subject: [PATCH 03/34] linting --- src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | 2 +- src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index ec4d7a0ca64b..fc46527915a0 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -63,8 +63,8 @@ use Illuminate\Queue\Console\BatchesTableCommand; use Illuminate\Queue\Console\ClearCommand as QueueClearCommand; use Illuminate\Queue\Console\FailedTableCommand; -use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand; use Illuminate\Queue\Console\FlushBatchCommand as FlushBatchQueueCommand; +use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand; use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Queue\Console\ListenCommand as QueueListenCommand; use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; diff --git a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php index c3533fa2ea2e..41850ab334f0 100644 --- a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php @@ -8,7 +8,6 @@ use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; use Illuminate\Bus\UpdatedBatchJobCounts; -use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\Facade; use Illuminate\Support\Str; From 910fad8cb2934f2c231f806b8b398ba95ef38dfe Mon Sep 17 00:00:00 2001 From: dmason30 Date: Tue, 22 Dec 2020 16:22:59 +0000 Subject: [PATCH 04/34] Remove interface method and add import --- src/Illuminate/Bus/BatchRepository.php | 8 -------- src/Illuminate/Bus/DatabaseBatchRepository.php | 6 ++++-- .../Queue/Console/FlushBatchCommand.php | 16 +++++++++++----- .../Testing/Fakes/BatchRepositoryFake.php | 5 +++-- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Illuminate/Bus/BatchRepository.php b/src/Illuminate/Bus/BatchRepository.php index 978da8204843..098ccef20ed6 100644 --- a/src/Illuminate/Bus/BatchRepository.php +++ b/src/Illuminate/Bus/BatchRepository.php @@ -89,12 +89,4 @@ public function delete(string $batchId); * @return mixed */ public function transaction(Closure $callback); - - /** - * Prune all of the entries older than the given date. - * - * @param \DateTimeInterface $before - * @return int - */ - public function prune(\DateTimeInterface $before); } diff --git a/src/Illuminate/Bus/DatabaseBatchRepository.php b/src/Illuminate/Bus/DatabaseBatchRepository.php index cc56ead8d649..3f025b06f9f2 100644 --- a/src/Illuminate/Bus/DatabaseBatchRepository.php +++ b/src/Illuminate/Bus/DatabaseBatchRepository.php @@ -4,6 +4,7 @@ use Carbon\CarbonImmutable; use Closure; +use DateTimeInterface; use Illuminate\Database\Connection; use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; @@ -246,12 +247,13 @@ public function transaction(Closure $callback) /** * Prune all of the entries older than the given date. * - * @param \DateTimeInterface $before + * @param DateTimeInterface $before * @return int */ - public function prune(\DateTimeInterface $before) + public function prune(DateTimeInterface $before) { $query = $this->connection->table($this->table) + ->whereNotNull('finished_at') ->where('finished_at', '<', $before->getTimestamp()); $totalDeleted = 0; diff --git a/src/Illuminate/Queue/Console/FlushBatchCommand.php b/src/Illuminate/Queue/Console/FlushBatchCommand.php index edfefb03fb1f..eaafe61908c7 100644 --- a/src/Illuminate/Queue/Console/FlushBatchCommand.php +++ b/src/Illuminate/Queue/Console/FlushBatchCommand.php @@ -25,16 +25,22 @@ class FlushBatchCommand extends Command /** * Execute the console command. * - * @return int|null + * @return void */ public function handle() { - $hours = $this->option('hours'); + $count = 0; - $before = Carbon::now()->subHours($hours); + $repository = $this->laravel[BatchRepository::class]; - $count = $this->laravel[BatchRepository::class]->prune($before); + if (method_exists($repository, 'prune')) { + $hours = $this->option('hours'); - $this->info("{$count} entries deleted successfully."); + $before = Carbon::now()->subHours($hours); + + $count = $repository->prune($before); + } + + $this->info("{$count} entries deleted!"); } } diff --git a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php index 41850ab334f0..7c109db7b882 100644 --- a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php @@ -4,6 +4,7 @@ use Carbon\CarbonImmutable; use Closure; +use DateTimeInterface; use Illuminate\Bus\Batch; use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; @@ -138,10 +139,10 @@ public function transaction(Closure $callback) /** * Prune all of the entries older than the given date. * - * @param \DateTimeInterface $before + * @param DateTimeInterface $before * @return int */ - public function prune(\DateTimeInterface $before) + public function prune(DateTimeInterface $before) { return 0; } From 3d95575f4688e53e46d8d9a10f748a87698709f4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 22 Dec 2020 11:00:14 -0600 Subject: [PATCH 05/34] version --- src/Illuminate/Foundation/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 451a0120b177..82860b6f7eb7 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -31,7 +31,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn * * @var string */ - const VERSION = '6.20.7'; + const VERSION = '6.20.8'; /** * The base path for the Laravel installation. From e73855b18dcfc645c36d2474f437e4e73dd3c11d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 22 Dec 2020 11:00:40 -0600 Subject: [PATCH 06/34] version --- src/Illuminate/Foundation/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 6ef4be78946e..89b2ede18866 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '7.30.0'; + const VERSION = '7.30.1'; /** * The base path for the Laravel installation. From 53e91ef529ece38cb613e57840fae8be64da1d32 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 23 Dec 2020 00:38:35 +0200 Subject: [PATCH 07/34] [6.x] update changelog --- CHANGELOG-6.x.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8ec4a08e9afe..078fe3776c23 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -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) From 85193e8fdd91c9ca9f705e3d861a3ca4377be646 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 23 Dec 2020 00:45:03 +0200 Subject: [PATCH 08/34] [7.x] update changelog --- CHANGELOG-6.x.md | 9 ++++++++- CHANGELOG-7.x.md | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8ec4a08e9afe..078fe3776c23 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -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) diff --git a/CHANGELOG-7.x.md b/CHANGELOG-7.x.md index 7ef94e06eee9..2a0534809019 100644 --- a/CHANGELOG-7.x.md +++ b/CHANGELOG-7.x.md @@ -1,6 +1,15 @@ # Release Notes for 7.x -## [Unreleased](https://github.com/laravel/framework/compare/v7.30.0...7.x) +## [Unreleased](https://github.com/laravel/framework/compare/v7.30.1...7.x) + + +## [v7.30.1 (2020-12-22)](https://github.com/laravel/framework/compare/v7.30.0...v7.30.1) + +### Fixed +- Backport for fix issue with polymorphic morphMaps with literal 0 ([#35487](https://github.com/laravel/framework/pull/35487)) +- Fixed mime validation for jpeg files ([#35518](https://github.com/laravel/framework/pull/35518)) +- 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)) ## [v7.30.0 (2020-12-01)](https://github.com/laravel/framework/compare/v7.29.3...v7.30.0) From e932a728f63cf8b6b3989f89d4ea02aa87091854 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 23 Dec 2020 01:05:34 +0200 Subject: [PATCH 09/34] [8.x] update changelog --- CHANGELOG-6.x.md | 9 ++++++++- CHANGELOG-8.x.md | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8ec4a08e9afe..078fe3776c23 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -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) diff --git a/CHANGELOG-8.x.md b/CHANGELOG-8.x.md index 12793d5c2139..ababd01e8e4c 100644 --- a/CHANGELOG-8.x.md +++ b/CHANGELOG-8.x.md @@ -1,6 +1,25 @@ # 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.0...8.x) + + +## [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) From e85247b13fd75329b16992dc255746865d43d1b8 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 23 Dec 2020 01:07:19 +0200 Subject: [PATCH 10/34] [8.x] update changelog --- CHANGELOG-8.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-8.x.md b/CHANGELOG-8.x.md index ababd01e8e4c..c0499d7f01e5 100644 --- a/CHANGELOG-8.x.md +++ b/CHANGELOG-8.x.md @@ -1,6 +1,12 @@ # Release Notes for 8.x -## [Unreleased](https://github.com/laravel/framework/compare/v8.20.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) From 8dc442578670197c05e80be90fb711c427f3c99c Mon Sep 17 00:00:00 2001 From: dmason30 Date: Wed, 23 Dec 2020 01:05:02 +0000 Subject: [PATCH 11/34] Change command signature and add new interface --- src/Illuminate/Bus/DatabaseBatchRepository.php | 2 +- src/Illuminate/Bus/Prunable.php | 16 ++++++++++++++++ .../Providers/ArtisanServiceProvider.php | 16 ++++++++-------- ...hBatchCommand.php => PruneBatchesCommand.php} | 7 ++++--- .../Testing/Fakes/BatchRepositoryFake.php | 12 ------------ 5 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 src/Illuminate/Bus/Prunable.php rename src/Illuminate/Queue/Console/{FlushBatchCommand.php => PruneBatchesCommand.php} (78%) diff --git a/src/Illuminate/Bus/DatabaseBatchRepository.php b/src/Illuminate/Bus/DatabaseBatchRepository.php index 3f025b06f9f2..bfad496fc352 100644 --- a/src/Illuminate/Bus/DatabaseBatchRepository.php +++ b/src/Illuminate/Bus/DatabaseBatchRepository.php @@ -9,7 +9,7 @@ use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; -class DatabaseBatchRepository implements BatchRepository +class DatabaseBatchRepository implements BatchRepository, Prunable { /** * The batch factory instance. diff --git a/src/Illuminate/Bus/Prunable.php b/src/Illuminate/Bus/Prunable.php new file mode 100644 index 000000000000..5441a00dc5bf --- /dev/null +++ b/src/Illuminate/Bus/Prunable.php @@ -0,0 +1,16 @@ + 'command.queue.clear', 'QueueFailed' => 'command.queue.failed', 'QueueFlush' => 'command.queue.flush', - 'QueueFlushBatch' => 'command.queue.flush-batch', 'QueueForget' => 'command.queue.forget', 'QueueListen' => 'command.queue.listen', + 'QueuePruneBatches' => 'command.queue.prune-batches', 'QueueRestart' => 'command.queue.restart', 'QueueRetry' => 'command.queue.retry', 'QueueRetryBatch' => 'command.queue.retry-batch', @@ -679,10 +679,10 @@ protected function registerQueueFlushCommand() * * @return void */ - protected function registerQueueFlushBatchCommand() + protected function registerQueueListenCommand() { - $this->app->singleton('command.queue.flush-batch', function () { - return new FlushBatchQueueCommand; + $this->app->singleton('command.queue.listen', function ($app) { + return new QueueListenCommand($app['queue.listener']); }); } @@ -691,10 +691,10 @@ protected function registerQueueFlushBatchCommand() * * @return void */ - protected function registerQueueListenCommand() + protected function registerQueuePruneBatchesCommand() { - $this->app->singleton('command.queue.listen', function ($app) { - return new QueueListenCommand($app['queue.listener']); + $this->app->singleton('command.queue.prune-batches', function () { + return new PruneBatchesQueueCommand; }); } diff --git a/src/Illuminate/Queue/Console/FlushBatchCommand.php b/src/Illuminate/Queue/Console/PruneBatchesCommand.php similarity index 78% rename from src/Illuminate/Queue/Console/FlushBatchCommand.php rename to src/Illuminate/Queue/Console/PruneBatchesCommand.php index eaafe61908c7..d30b6fdb0e8d 100644 --- a/src/Illuminate/Queue/Console/FlushBatchCommand.php +++ b/src/Illuminate/Queue/Console/PruneBatchesCommand.php @@ -4,16 +4,17 @@ use Carbon\Carbon; use Illuminate\Bus\BatchRepository; +use Illuminate\Bus\Prunable; use Illuminate\Console\Command; -class FlushBatchCommand extends Command +class PruneBatchesCommand extends Command { /** * The console command signature. * * @var string */ - protected $signature = 'queue:flush-batch {--hours=24 : The number of hours to retain batch data}'; + protected $signature = 'queue:prune-batches {--hours=24 : The number of hours to retain batch data}'; /** * The console command description. @@ -33,7 +34,7 @@ public function handle() $repository = $this->laravel[BatchRepository::class]; - if (method_exists($repository, 'prune')) { + if ($repository instanceof Prunable) { $hours = $this->option('hours'); $before = Carbon::now()->subHours($hours); diff --git a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php index 7c109db7b882..55681f4d5534 100644 --- a/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php @@ -4,7 +4,6 @@ use Carbon\CarbonImmutable; use Closure; -use DateTimeInterface; use Illuminate\Bus\Batch; use Illuminate\Bus\BatchRepository; use Illuminate\Bus\PendingBatch; @@ -135,15 +134,4 @@ public function transaction(Closure $callback) { return $callback(); } - - /** - * Prune all of the entries older than the given date. - * - * @param DateTimeInterface $before - * @return int - */ - public function prune(DateTimeInterface $before) - { - return 0; - } } From 843f8bb4269bb983826ba709d49cd697a040e85a Mon Sep 17 00:00:00 2001 From: Karel Faille Date: Wed, 23 Dec 2020 15:08:30 +0100 Subject: [PATCH 12/34] Ensure DBAL custom type doesn't exists (#35704) As the DBAL type registry is a static singleton, when running multiple tests, type may be already registered. --- src/Illuminate/Database/DatabaseServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/DatabaseServiceProvider.php b/src/Illuminate/Database/DatabaseServiceProvider.php index 72f131d0db49..9f2ab18503e1 100755 --- a/src/Illuminate/Database/DatabaseServiceProvider.php +++ b/src/Illuminate/Database/DatabaseServiceProvider.php @@ -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); + } } } } From 658bd91ff339782124047f5d8e5df7654d29463b Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Wed, 23 Dec 2020 14:44:51 +0000 Subject: [PATCH 13/34] chore: remove duplicate doc block (#35705) --- .../Http/Middleware/PreventRequestsDuringMaintenance.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php index 99953bfd5e90..831468281fbc 100644 --- a/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -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) { From 33f5ac695a55d6cdbadcfe1b46e3409e4a66df16 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 24 Dec 2020 12:50:47 -0600 Subject: [PATCH 14/34] add files --- .../Bus/DatabaseBatchRepository.php | 30 +++++++++---------- ...unable.php => PrunableBatchRepository.php} | 4 +-- .../Queue/Console/PruneBatchesCommand.php | 6 +--- 3 files changed, 18 insertions(+), 22 deletions(-) rename src/Illuminate/Bus/{Prunable.php => PrunableBatchRepository.php} (68%) diff --git a/src/Illuminate/Bus/DatabaseBatchRepository.php b/src/Illuminate/Bus/DatabaseBatchRepository.php index bfad496fc352..ece6301c126f 100644 --- a/src/Illuminate/Bus/DatabaseBatchRepository.php +++ b/src/Illuminate/Bus/DatabaseBatchRepository.php @@ -9,7 +9,7 @@ use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; -class DatabaseBatchRepository implements BatchRepository, Prunable +class DatabaseBatchRepository implements PrunableBatchRepository { /** * The batch factory instance. @@ -231,23 +231,10 @@ public function delete(string $batchId) $this->connection->table($this->table)->where('id', $batchId)->delete(); } - /** - * Execute the given Closure within a storage specific transaction. - * - * @param \Closure $callback - * @return mixed - */ - public function transaction(Closure $callback) - { - return $this->connection->transaction(function () use ($callback) { - return $callback(); - }); - } - /** * Prune all of the entries older than the given date. * - * @param DateTimeInterface $before + * @param \DateTimeInterface $before * @return int */ public function prune(DateTimeInterface $before) @@ -267,6 +254,19 @@ public function prune(DateTimeInterface $before) return $totalDeleted; } + /** + * Execute the given Closure within a storage specific transaction. + * + * @param \Closure $callback + * @return mixed + */ + public function transaction(Closure $callback) + { + return $this->connection->transaction(function () use ($callback) { + return $callback(); + }); + } + /** * Convert the given raw batch to a Batch object. * diff --git a/src/Illuminate/Bus/Prunable.php b/src/Illuminate/Bus/PrunableBatchRepository.php similarity index 68% rename from src/Illuminate/Bus/Prunable.php rename to src/Illuminate/Bus/PrunableBatchRepository.php index 5441a00dc5bf..3f972553b597 100644 --- a/src/Illuminate/Bus/Prunable.php +++ b/src/Illuminate/Bus/PrunableBatchRepository.php @@ -4,12 +4,12 @@ use DateTimeInterface; -interface Prunable +interface PrunableBatchRepository extends BatchRepository { /** * Prune all of the entries older than the given date. * - * @param DateTimeInterface $before + * @param \DateTimeInterface $before * @return int */ public function prune(DateTimeInterface $before); diff --git a/src/Illuminate/Queue/Console/PruneBatchesCommand.php b/src/Illuminate/Queue/Console/PruneBatchesCommand.php index d30b6fdb0e8d..e519c9a7759d 100644 --- a/src/Illuminate/Queue/Console/PruneBatchesCommand.php +++ b/src/Illuminate/Queue/Console/PruneBatchesCommand.php @@ -35,11 +35,7 @@ public function handle() $repository = $this->laravel[BatchRepository::class]; if ($repository instanceof Prunable) { - $hours = $this->option('hours'); - - $before = Carbon::now()->subHours($hours); - - $count = $repository->prune($before); + $count = $repository->prune(Carbon::now()->subHours($this->option('hours'))); } $this->info("{$count} entries deleted!"); From 344710f021c5b5b8fb32f6f66c5301829aa5758a Mon Sep 17 00:00:00 2001 From: Daniel Mason Date: Fri, 25 Dec 2020 04:02:42 +0000 Subject: [PATCH 15/34] Fix prune batches command interface check (#35713) The `Prunable` interface I added was renamed to `PrunableBatchRepository` post merge but was not also changed in the command interface check to see if the repository can be pruned. --- src/Illuminate/Queue/Console/PruneBatchesCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/PruneBatchesCommand.php b/src/Illuminate/Queue/Console/PruneBatchesCommand.php index e519c9a7759d..cc25bc53cfb9 100644 --- a/src/Illuminate/Queue/Console/PruneBatchesCommand.php +++ b/src/Illuminate/Queue/Console/PruneBatchesCommand.php @@ -4,7 +4,7 @@ use Carbon\Carbon; use Illuminate\Bus\BatchRepository; -use Illuminate\Bus\Prunable; +use Illuminate\Bus\PrunableBatchRepository; use Illuminate\Console\Command; class PruneBatchesCommand extends Command @@ -34,7 +34,7 @@ public function handle() $repository = $this->laravel[BatchRepository::class]; - if ($repository instanceof Prunable) { + if ($repository instanceof PrunableBatchRepository) { $count = $repository->prune(Carbon::now()->subHours($this->option('hours'))); } From 08303c7cbaa0b3271060ce315160d0722b2a78f0 Mon Sep 17 00:00:00 2001 From: Daniel Esteve Date: Fri, 25 Dec 2020 18:37:09 +0100 Subject: [PATCH 16/34] [8.x] Add missing dispatchAfterCommit to DatabaseQueue (#35715) * add missing dispatchAfterCommit to DatabaseQueue * add new param to phpdoc --- src/Illuminate/Queue/DatabaseQueue.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/DatabaseQueue.php b/src/Illuminate/Queue/DatabaseQueue.php index 961b4e460b04..cc77007c0b2f 100644 --- a/src/Illuminate/Queue/DatabaseQueue.php +++ b/src/Illuminate/Queue/DatabaseQueue.php @@ -47,14 +47,20 @@ class DatabaseQueue extends Queue implements QueueContract, ClearableQueue * @param string $table * @param string $default * @param int $retryAfter + * @param bool $dispatchAfterCommit * @return void */ - public function __construct(Connection $database, $table, $default = 'default', $retryAfter = 60) + public function __construct(Connection $database, + $table, + $default = 'default', + $retryAfter = 60, + $dispatchAfterCommit = false) { $this->table = $table; $this->default = $default; $this->database = $database; $this->retryAfter = $retryAfter; + $this->dispatchAfterCommit = $dispatchAfterCommit; } /** From aae5c4acf3492ffac107ac2e466914e455623da8 Mon Sep 17 00:00:00 2001 From: Hamid Alaei Varnosfaderani Date: Sat, 26 Dec 2020 19:27:28 +0330 Subject: [PATCH 17/34] convert time to seconds once (#35721) --- src/Illuminate/Cache/Repository.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 46af170f2b40..00cd39b013a4 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -292,8 +292,12 @@ public function setMultiple($values, $ttl = null) */ public function add($key, $value, $ttl = null) { + $seconds = null; + if ($ttl !== null) { - if ($this->getSeconds($ttl) <= 0) { + $seconds = $this->getSeconds($ttl); + + if ($seconds <= 0) { return false; } @@ -301,8 +305,6 @@ public function add($key, $value, $ttl = null) // has a chance to override this logic. Some drivers better support the way // this operation should work with a total "atomic" implementation of it. if (method_exists($this->store, 'add')) { - $seconds = $this->getSeconds($ttl); - return $this->store->add( $this->itemKey($key), $value, $seconds ); @@ -313,7 +315,7 @@ public function add($key, $value, $ttl = null) // so it exists for subsequent requests. Then, we will return true so it is // easy to know if the value gets added. Otherwise, we will return false. if (is_null($this->get($key))) { - return $this->put($key, $value, $ttl); + return $this->put($key, $value, $seconds); } return false; From 7f42f67d9b4e4e64a4d8706960d7720ba4204ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Mon, 28 Dec 2020 03:42:09 +0200 Subject: [PATCH 18/34] Fix `php artisan db` command for the Postgres CLI (#35725) --- src/Illuminate/Database/Console/DbCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/DbCommand.php b/src/Illuminate/Database/Console/DbCommand.php index ee6633557017..9152d1dc844c 100644 --- a/src/Illuminate/Database/Console/DbCommand.php +++ b/src/Illuminate/Database/Console/DbCommand.php @@ -83,7 +83,7 @@ public function commandEnvironment(array $connection) { $driver = ucfirst($connection['driver']); - if (method_exists($this, "get{$driver}Env")) { + if (method_exists($this, "get{$driver}Environment")) { return $this->{"get{$driver}Environment"}($connection); } From 0be33dedabf671cdf3278edf8c61a3ced85abb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Tue, 29 Dec 2020 01:04:41 +0200 Subject: [PATCH 19/34] Since documentation was reviewed test case naming convention has changed to `snake_case`. I guess it makes sense to update test stubs for new projects too. (#35735) --- src/Illuminate/Foundation/Console/stubs/test.stub | 2 +- src/Illuminate/Foundation/Console/stubs/test.unit.stub | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/stubs/test.stub b/src/Illuminate/Foundation/Console/stubs/test.stub index c5b50ad3cb6b..84c75cbfe98d 100644 --- a/src/Illuminate/Foundation/Console/stubs/test.stub +++ b/src/Illuminate/Foundation/Console/stubs/test.stub @@ -13,7 +13,7 @@ class {{ class }} extends TestCase * * @return void */ - public function testExample() + public function test_example() { $response = $this->get('/'); diff --git a/src/Illuminate/Foundation/Console/stubs/test.unit.stub b/src/Illuminate/Foundation/Console/stubs/test.unit.stub index 98af6529355c..b6816aa72f29 100644 --- a/src/Illuminate/Foundation/Console/stubs/test.unit.stub +++ b/src/Illuminate/Foundation/Console/stubs/test.unit.stub @@ -11,7 +11,7 @@ class {{ class }} extends TestCase * * @return void */ - public function testExample() + public function test_example() { $this->assertTrue(true); } From 75a0753879419c91dfacb5aecf584aa260714620 Mon Sep 17 00:00:00 2001 From: MilesChou Date: Tue, 29 Dec 2020 07:09:49 +0800 Subject: [PATCH 20/34] Fix OPTIONS method bug when use same path but diff domain (#35714) --- .../Routing/CompiledRouteCollection.php | 4 ++ .../Routing/CompiledRouteCollectionTest.php | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/Illuminate/Routing/CompiledRouteCollection.php b/src/Illuminate/Routing/CompiledRouteCollection.php index 099156cc4b81..c53954194e06 100644 --- a/src/Illuminate/Routing/CompiledRouteCollection.php +++ b/src/Illuminate/Routing/CompiledRouteCollection.php @@ -252,6 +252,10 @@ public function getRoutesByMethod() }) ->map(function (Collection $routes) { return $routes->mapWithKeys(function (Route $route) { + if ($domain = $route->getDomain()) { + return [$domain.'/'.$route->uri => $route]; + } + return [$route->uri => $route]; })->all(); }) diff --git a/tests/Integration/Routing/CompiledRouteCollectionTest.php b/tests/Integration/Routing/CompiledRouteCollectionTest.php index 22928a4c1f4f..e474e8a461c4 100644 --- a/tests/Integration/Routing/CompiledRouteCollectionTest.php +++ b/tests/Integration/Routing/CompiledRouteCollectionTest.php @@ -490,6 +490,59 @@ public function testTrailingSlashIsTrimmedWhenMatchingCachedRoutes() $this->assertSame('foo', $this->collection()->match($request)->getName()); } + public function testRouteWithSamePathAndSameMethodButDiffDomainNameWithOptionsMethod() + { + $routes = [ + 'foo_domain' => $this->newRoute('GET', 'same/path', [ + 'uses' => 'FooController@index', + 'as' => 'foo', + 'domain' => 'foo.localhost', + ]), + 'bar_domain' => $this->newRoute('GET', 'same/path', [ + 'uses' => 'BarController@index', + 'as' => 'bar', + 'domain' => 'bar.localhost', + ]), + 'no_domain' => $this->newRoute('GET', 'same/path', [ + 'uses' => 'BarController@index', + 'as' => 'no_domain', + ]), + ]; + + $this->routeCollection->add($routes['foo_domain']); + $this->routeCollection->add($routes['bar_domain']); + $this->routeCollection->add($routes['no_domain']); + + $expectedMethods = [ + 'OPTIONS', + ]; + + $this->assertSame($expectedMethods, $this->collection()->match( + Request::create('http://foo.localhost/same/path', 'OPTIONS') + )->methods); + + $this->assertSame($expectedMethods, $this->collection()->match( + Request::create('http://bar.localhost/same/path', 'OPTIONS') + )->methods); + + $this->assertSame($expectedMethods, $this->collection()->match( + Request::create('http://no.localhost/same/path', 'OPTIONS') + )->methods); + + $this->assertEquals([ + 'HEAD' => [ + 'foo.localhost/same/path' => $routes['foo_domain'], + 'bar.localhost/same/path' => $routes['bar_domain'], + 'same/path' => $routes['no_domain'], + ], + 'GET' => [ + 'foo.localhost/same/path' => $routes['foo_domain'], + 'bar.localhost/same/path' => $routes['bar_domain'], + 'same/path' => $routes['no_domain'], + ], + ], $this->collection()->getRoutesByMethod()); + } + /** * Create a new Route object. * From 13546a703c210298517b25307647778d4fe3ab9f Mon Sep 17 00:00:00 2001 From: Sab Date: Tue, 29 Dec 2020 13:57:03 +1100 Subject: [PATCH 21/34] Update DetectsLostConnections.php (#35744) AWS Aurora serverless DB sometimes aborts queries while performing scaling. The error returned is: "SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry." --- src/Illuminate/Database/DetectsLostConnections.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Database/DetectsLostConnections.php b/src/Illuminate/Database/DetectsLostConnections.php index c214c0396c84..6ba3c4939faa 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -47,6 +47,7 @@ protected function causedByLostConnection(Throwable $e) 'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: EOF detected', 'SQLSTATE[HY000] [2002] Connection timed out', 'SSL: Connection timed out', + 'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', ]); } } From 2ce11abecb868af99f311ea8731a8cd9cb8a99d8 Mon Sep 17 00:00:00 2001 From: Roelof Date: Tue, 29 Dec 2020 16:08:35 +0100 Subject: [PATCH 22/34] [8.x] Correct return type on View facade's first() (#35750) * Fixed docblock in View facade * Added test assertion to make sure View facade docblock is correct --- src/Illuminate/Support/Facades/View.php | 2 +- tests/View/ViewFactoryTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Facades/View.php b/src/Illuminate/Support/Facades/View.php index b85b086c5547..9b66464c9d96 100755 --- a/src/Illuminate/Support/Facades/View.php +++ b/src/Illuminate/Support/Facades/View.php @@ -4,7 +4,7 @@ /** * @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string|array $hints) - * @method static \Illuminate\Contracts\View\Factory first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) + * @method static \Illuminate\Contracts\View\View first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = []) * @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string|array $hints) * @method static \Illuminate\Contracts\View\View file(string $path, array $data = [], array $mergeData = []) * @method static \Illuminate\Contracts\View\View make(string $view, array $data = [], array $mergeData = []) diff --git a/tests/View/ViewFactoryTest.php b/tests/View/ViewFactoryTest.php index 52061422074e..ab003c3b9f9d 100755 --- a/tests/View/ViewFactoryTest.php +++ b/tests/View/ViewFactoryTest.php @@ -7,6 +7,7 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Contracts\View\Engine; +use Illuminate\Contracts\View\View as ViewContract; use Illuminate\Events\Dispatcher; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\HtmlString; @@ -87,6 +88,7 @@ public function testFirstCreatesNewViewInstanceWithProperPath() $factory->addExtension('php', 'php'); $view = $factory->first(['bar', 'view'], ['foo' => 'bar'], ['baz' => 'boom']); + $this->assertInstanceOf(ViewContract::class, $view); $this->assertSame($engine, $view->getEngine()); $this->assertSame($_SERVER['__test.view'], $view); From d44ed21525a9bf1a12717c92318e9dcd3a1427d1 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 29 Dec 2020 17:18:15 +0200 Subject: [PATCH 23/34] [8.x] Set chain queue when inside a batch (#35746) * set chain copnnection when inside a batch * set chain connection from batch --- src/Illuminate/Bus/Batch.php | 5 ++++- tests/Bus/BusBatchTest.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Bus/Batch.php b/src/Illuminate/Bus/Batch.php index 1073ecd46d37..cac16e1e9f51 100644 --- a/src/Illuminate/Bus/Batch.php +++ b/src/Illuminate/Bus/Batch.php @@ -170,7 +170,10 @@ public function add($jobs) $count += count($job); return with($this->prepareBatchedChain($job), function ($chain) { - return $chain->first()->chain($chain->slice(1)->values()->all()); + return $chain->first() + ->allOnQueue($this->options['queue'] ?? null) + ->allOnConnection($this->options['connection'] ?? null) + ->chain($chain->slice(1)->values()->all()); }); } else { $job->withBatchId($this->id); diff --git a/tests/Bus/BusBatchTest.php b/tests/Bus/BusBatchTest.php index 381200daa171..8f4d6c5a11d4 100644 --- a/tests/Bus/BusBatchTest.php +++ b/tests/Bus/BusBatchTest.php @@ -332,6 +332,7 @@ public function test_chain_can_be_added_to_batch() $this->assertEquals(3, $batch->totalJobs); $this->assertEquals(3, $batch->pendingJobs); + $this->assertEquals('test-queue', $chainHeadJob->chainQueue); $this->assertTrue(is_string($chainHeadJob->batchId)); $this->assertTrue(is_string($secondJob->batchId)); $this->assertTrue(is_string($thirdJob->batchId)); From 60c3c81d083f63a5581b97e2d38375227fc86f9e Mon Sep 17 00:00:00 2001 From: Christoph Rumpel Date: Wed, 30 Dec 2020 00:19:59 +0100 Subject: [PATCH 24/34] Check for given message stream id and add to header if given (#35755) Co-authored-by: Christoph Rumpel --- src/Illuminate/Mail/MailManager.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Mail/MailManager.php b/src/Illuminate/Mail/MailManager.php index a8a4a291d0c9..97fcda7827c5 100644 --- a/src/Illuminate/Mail/MailManager.php +++ b/src/Illuminate/Mail/MailManager.php @@ -327,8 +327,13 @@ protected function createMailgunTransport(array $config) */ protected function createPostmarkTransport(array $config) { + $headers = isset($config['message_stream_id']) ? [ + 'X-PM-Message-Stream' => $config['message_stream_id'], + ] : []; + return tap(new PostmarkTransport( - $config['token'] ?? $this->app['config']->get('services.postmark.token') + $config['token'] ?? $this->app['config']->get('services.postmark.token'), + $headers ), function ($transport) { $transport->registerPlugin(new ThrowExceptionOnFailurePlugin()); }); From 2c9c12c5e41b3f13bcf9d7374417c0d211ae4dd9 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Wed, 30 Dec 2020 00:21:31 +0100 Subject: [PATCH 25/34] Fix setUp and tearDown methods visibility (#35753) --- tests/Cache/CacheMemcachedStoreTest.php | 2 +- tests/Integration/Foundation/MaintenanceModeTest.php | 2 +- tests/View/Blade/BladeComponentTagCompilerTest.php | 2 +- tests/View/ComponentTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Cache/CacheMemcachedStoreTest.php b/tests/Cache/CacheMemcachedStoreTest.php index 5b29dd70b279..b1aad12ad29d 100755 --- a/tests/Cache/CacheMemcachedStoreTest.php +++ b/tests/Cache/CacheMemcachedStoreTest.php @@ -11,7 +11,7 @@ class CacheMemcachedStoreTest extends TestCase { - public function tearDown(): void + protected function tearDown(): void { m::close(); diff --git a/tests/Integration/Foundation/MaintenanceModeTest.php b/tests/Integration/Foundation/MaintenanceModeTest.php index 31f08df44da9..ff93fe41a492 100644 --- a/tests/Integration/Foundation/MaintenanceModeTest.php +++ b/tests/Integration/Foundation/MaintenanceModeTest.php @@ -14,7 +14,7 @@ */ class MaintenanceModeTest extends TestCase { - public function tearDown(): void + protected function tearDown(): void { @unlink(storage_path('framework/down')); } diff --git a/tests/View/Blade/BladeComponentTagCompilerTest.php b/tests/View/Blade/BladeComponentTagCompilerTest.php index 6872d38ae4a1..b84030c13d2b 100644 --- a/tests/View/Blade/BladeComponentTagCompilerTest.php +++ b/tests/View/Blade/BladeComponentTagCompilerTest.php @@ -13,7 +13,7 @@ class BladeComponentTagCompilerTest extends AbstractBladeTestCase { - public function tearDown(): void + protected function tearDown(): void { Mockery::close(); } diff --git a/tests/View/ComponentTest.php b/tests/View/ComponentTest.php index 124d954d454e..8049c7aa5bc5 100644 --- a/tests/View/ComponentTest.php +++ b/tests/View/ComponentTest.php @@ -19,7 +19,7 @@ class ComponentTest extends TestCase protected $viewFactory; protected $config; - public function setUp(): void + protected function setUp(): void { $this->config = m::mock(Config::class); From 4da7a2b43699b896e5b3f62c4e43039effecaf14 Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Fri, 1 Jan 2021 11:06:10 -0600 Subject: [PATCH 26/34] [8.x] Give a more meaningul message when route parameters are missing (#35706) * Give a more meaningul message when route parameters are missing The message for `UrlGenerationException` when parameters are missing is a nice start, but knowing which parameters are missing can be a huge help in figuring out where something is broken. Especially if a route has multiple possible parameters. Which parameter is actually missing? Are more than one missing? Now we'll know! * Fix small typo Co-authored-by: Michel Bardelmeijer Co-authored-by: Michel Bardelmeijer --- .../Exceptions/UrlGenerationException.php | 22 +++++++- src/Illuminate/Routing/RouteUrlGenerator.php | 4 +- tests/Routing/RoutingRouteTest.php | 2 +- tests/Routing/RoutingUrlGeneratorTest.php | 55 +++++++++++++++++++ 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Routing/Exceptions/UrlGenerationException.php b/src/Illuminate/Routing/Exceptions/UrlGenerationException.php index 1853b2aff0fc..330e8c223814 100644 --- a/src/Illuminate/Routing/Exceptions/UrlGenerationException.php +++ b/src/Illuminate/Routing/Exceptions/UrlGenerationException.php @@ -3,6 +3,8 @@ namespace Illuminate\Routing\Exceptions; use Exception; +use Illuminate\Routing\Route; +use Illuminate\Support\Str; class UrlGenerationException extends Exception { @@ -10,10 +12,26 @@ class UrlGenerationException extends Exception * Create a new exception for missing route parameters. * * @param \Illuminate\Routing\Route $route + * @param array $parameters * @return static */ - public static function forMissingParameters($route) + public static function forMissingParameters(Route $route, array $parameters = []) { - return new static("Missing required parameters for [Route: {$route->getName()}] [URI: {$route->uri()}]."); + $parameterLabel = Str::plural('parameter', count($parameters)); + + $message = sprintf( + 'Missing required %s for [Route: %s] [URI: %s]', + $parameterLabel, + $route->getName(), + $route->uri() + ); + + if (count($parameters) > 0) { + $message .= sprintf(' [Missing %s: %s]', $parameterLabel, implode(', ', $parameters)); + } + + $message .= '.'; + + return new static($message); } } diff --git a/src/Illuminate/Routing/RouteUrlGenerator.php b/src/Illuminate/Routing/RouteUrlGenerator.php index 5cc03c1e246c..5f1248966c77 100644 --- a/src/Illuminate/Routing/RouteUrlGenerator.php +++ b/src/Illuminate/Routing/RouteUrlGenerator.php @@ -87,8 +87,8 @@ public function to($route, $parameters = [], $absolute = false) $route ), $parameters); - if (preg_match('/\{.*?\}/', $uri)) { - throw UrlGenerationException::forMissingParameters($route); + if (preg_match_all('/{(.*?)}/', $uri, $matchedMissingParameters)) { + throw UrlGenerationException::forMissingParameters($route, $matchedMissingParameters[1]); } // Once we have ensured that there are no missing parameters in the URI we will encode diff --git a/tests/Routing/RoutingRouteTest.php b/tests/Routing/RoutingRouteTest.php index 6715aa7297d9..9a9f76e8123f 100644 --- a/tests/Routing/RoutingRouteTest.php +++ b/tests/Routing/RoutingRouteTest.php @@ -1831,7 +1831,7 @@ public function testRouteRedirectStripsMissingStartingForwardSlash() public function testRouteRedirectExceptionWhenMissingExpectedParameters() { $this->expectException(UrlGenerationException::class); - $this->expectExceptionMessage('Missing required parameters for [Route: laravel_route_redirect_destination] [URI: users/{user}].'); + $this->expectExceptionMessage('Missing required parameter for [Route: laravel_route_redirect_destination] [URI: users/{user}] [Missing parameter: user].'); $container = new Container; $router = new Router(new Dispatcher, $container); diff --git a/tests/Routing/RoutingUrlGeneratorTest.php b/tests/Routing/RoutingUrlGeneratorTest.php index b7663b686b17..676f609b15fa 100755 --- a/tests/Routing/RoutingUrlGeneratorTest.php +++ b/tests/Routing/RoutingUrlGeneratorTest.php @@ -550,6 +550,61 @@ public function testUrlGenerationForControllersRequiresPassingOfRequiredParamete $this->assertSame('http://www.foo.com:8080/foo?test=123', $url->route('foo', $parameters)); } + public function provideParametersAndExpectedMeaningfulExceptionMessages() + { + return [ + 'Missing parameters "one", "two" and "three"' => [ + [], + 'Missing required parameters for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameters: one, two, three].', + ], + 'Missing parameters "two" and "three"' => [ + ['one' => '123'], + 'Missing required parameters for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameters: two, three].', + ], + 'Missing parameters "one" and "three"' => [ + ['two' => '123'], + 'Missing required parameters for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameters: one, three].', + ], + 'Missing parameters "one" and "two"' => [ + ['three' => '123'], + 'Missing required parameters for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameters: one, two].', + ], + 'Missing parameter "three"' => [ + ['one' => '123', 'two' => '123'], + 'Missing required parameter for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameter: three].', + ], + 'Missing parameter "two"' => [ + ['one' => '123', 'three' => '123'], + 'Missing required parameter for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameter: two].', + ], + 'Missing parameter "one"' => [ + ['two' => '123', 'three' => '123'], + 'Missing required parameter for [Route: foo] [URI: foo/{one}/{two}/{three}/{four?}] [Missing parameter: one].', + ], + ]; + } + + /** + * @dataProvider provideParametersAndExpectedMeaningfulExceptionMessages + */ + public function testUrlGenerationThrowsExceptionForMissingParametersWithMeaningfulMessage($parameters, $expectedMeaningfulExceptionMessage) + { + $this->expectException(UrlGenerationException::class); + $this->expectExceptionMessage($expectedMeaningfulExceptionMessage); + + $url = new UrlGenerator( + $routes = new RouteCollection, + Request::create('http://www.foo.com:8080/') + ); + + $route = new Route(['GET'], 'foo/{one}/{two}/{three}/{four?}', ['as' => 'foo', function () { + // + }]); + $routes->add($route); + + $url->route('foo', $parameters); + } + public function testForceRootUrl() { $url = new UrlGenerator( From 334b0a9b9ebd02b8207816e37058700e52876cfc Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 1 Jan 2021 11:06:33 -0600 Subject: [PATCH 27/34] formatting --- src/Illuminate/Routing/Exceptions/UrlGenerationException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Routing/Exceptions/UrlGenerationException.php b/src/Illuminate/Routing/Exceptions/UrlGenerationException.php index 330e8c223814..e0057c9d6bbf 100644 --- a/src/Illuminate/Routing/Exceptions/UrlGenerationException.php +++ b/src/Illuminate/Routing/Exceptions/UrlGenerationException.php @@ -12,7 +12,7 @@ class UrlGenerationException extends Exception * Create a new exception for missing route parameters. * * @param \Illuminate\Routing\Route $route - * @param array $parameters + * @param array $parameters * @return static */ public static function forMissingParameters(Route $route, array $parameters = []) From 4ffe40fb169c6bcce9193ff56958eca41e64294f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 2 Jan 2021 15:32:04 -0600 Subject: [PATCH 28/34] add table prefix --- src/Illuminate/Database/Console/DumpCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/DumpCommand.php b/src/Illuminate/Database/Console/DumpCommand.php index e7b60c7efa7c..fe73fb2af033 100644 --- a/src/Illuminate/Database/Console/DumpCommand.php +++ b/src/Illuminate/Database/Console/DumpCommand.php @@ -66,7 +66,7 @@ public function handle(ConnectionResolverInterface $connections, Dispatcher $dis protected function schemaState(Connection $connection) { return $connection->getSchemaState() - ->withMigrationTable(Config::get('database.migrations', 'migrations')) + ->withMigrationTable($connection->getTablePrefix().Config::get('database.migrations', 'migrations')) ->handleOutputUsing(function ($type, $buffer) { $this->output->write($buffer); }); From 44dbb4b606d7a049fb3b95594b495567a7c29223 Mon Sep 17 00:00:00 2001 From: David Siegers Date: Mon, 4 Jan 2021 15:52:00 +0100 Subject: [PATCH 29/34] Remove if-condition that always evaluates to false (#35771) The if-condition at src/Illuminate/Queue/RedisQueue.php:212 never evaluates to true and its early-return statement is never executed because $nextJob is never empty. $nextJob is never empty because \Illuminate\Queue\RedisQueue::retrieveNextJob can only return [null, null] or [$job, $reserved] which are both none-empty-arrays. Consequently we can remove the if-condition and its unreachable statement without causing any change to behaviour. --- src/Illuminate/Queue/RedisQueue.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Illuminate/Queue/RedisQueue.php b/src/Illuminate/Queue/RedisQueue.php index 3aca40c9c388..79efc0581f24 100644 --- a/src/Illuminate/Queue/RedisQueue.php +++ b/src/Illuminate/Queue/RedisQueue.php @@ -209,11 +209,7 @@ public function pop($queue = null) { $this->migrate($prefixed = $this->getQueue($queue)); - if (empty($nextJob = $this->retrieveNextJob($prefixed))) { - return; - } - - [$job, $reserved] = $nextJob; + [$job, $reserved] = $this->retrieveNextJob($prefixed); if ($reserved) { return new RedisJob( From 72596ae3612bb6dfa21468f8d7d77f6cc545890d Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:13:36 -0500 Subject: [PATCH 30/34] Refresh the retryUntil timer on job retry Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index e9120a976962..28491debd2e9 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -93,10 +93,25 @@ protected function getJobIdsByRanges(array $ranges) protected function retryJob($job) { $this->laravel['queue']->connection($job->connection)->pushRaw( - $this->resetAttempts($job->payload), $job->queue + $this->retryRefresh($job->payload), $job->queue ); } + /** + * Possibly refresh job attempts and retryUntil value + * + * @param string $payload + * @return string + */ + protected function retryRefresh($payload) + { + $payload = $this->resetAttempts($payload); + + $payload = $this->refreshRetryUntil($payload); + + return $payload; + } + /** * Reset the payload attempts. * @@ -115,4 +130,23 @@ protected function resetAttempts($payload) return json_encode($payload); } + + /** + * Refreshes a jobs retryUntil time with it's own retryUntil method + * + * @param string $payload + * @return string + */ + protected function refreshRetryUntil($payload) + { + $payload = json_decode($payload, true); + + $jobInstance = unserialize($payload['data']['command']); + + $newRetryUntil = $jobInstance->retryUntil()->timestamp; + + $payload['retryUntil'] = $newRetryUntil; + + return json_encode($payload); + } } From d91253be99029a27caa225caa47bf80645a0c21e Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:26:28 -0500 Subject: [PATCH 31/34] Check if the job has a retryUntil method Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 28491debd2e9..e5c4dc0af03a 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -143,9 +143,11 @@ protected function refreshRetryUntil($payload) $jobInstance = unserialize($payload['data']['command']); - $newRetryUntil = $jobInstance->retryUntil()->timestamp; + if (method_exists($jobInstance, 'retryUntil')) { + $newRetryUntil = $jobInstance->retryUntil()->timestamp; - $payload['retryUntil'] = $newRetryUntil; + $payload['retryUntil'] = $newRetryUntil; + } return json_encode($payload); } From cdcc60bad460348f72b07501aa0010673b27727f Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 4 Jan 2021 22:43:41 -0500 Subject: [PATCH 32/34] Proper punctuation Signed-off-by: Kevin Ullyott --- src/Illuminate/Queue/Console/RetryCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index e5c4dc0af03a..055790da6446 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -98,7 +98,7 @@ protected function retryJob($job) } /** - * Possibly refresh job attempts and retryUntil value + * Possibly refresh job attempts and retryUntil value. * * @param string $payload * @return string @@ -132,7 +132,7 @@ protected function resetAttempts($payload) } /** - * Refreshes a jobs retryUntil time with it's own retryUntil method + * Refreshes a jobs retryUntil time with it's own retryUntil method. * * @param string $payload * @return string From 45eb7a7b1706ae175268731a673f369c0e556805 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 5 Jan 2021 08:56:06 -0600 Subject: [PATCH 33/34] formatting --- src/Illuminate/Queue/Console/RetryCommand.php | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/Illuminate/Queue/Console/RetryCommand.php b/src/Illuminate/Queue/Console/RetryCommand.php index 055790da6446..fe6248800c99 100644 --- a/src/Illuminate/Queue/Console/RetryCommand.php +++ b/src/Illuminate/Queue/Console/RetryCommand.php @@ -93,29 +93,14 @@ protected function getJobIdsByRanges(array $ranges) protected function retryJob($job) { $this->laravel['queue']->connection($job->connection)->pushRaw( - $this->retryRefresh($job->payload), $job->queue + $this->refreshRetryUntil($this->resetAttempts($job->payload)), $job->queue ); } - /** - * Possibly refresh job attempts and retryUntil value. - * - * @param string $payload - * @return string - */ - protected function retryRefresh($payload) - { - $payload = $this->resetAttempts($payload); - - $payload = $this->refreshRetryUntil($payload); - - return $payload; - } - /** * Reset the payload attempts. * - * Applicable to Redis jobs which store attempts in their payload. + * Applicable to Redis and other jobs which store attempts in their payload. * * @param string $payload * @return string @@ -132,7 +117,7 @@ protected function resetAttempts($payload) } /** - * Refreshes a jobs retryUntil time with it's own retryUntil method. + * Refresh the "retry until" timestamp for the job. * * @param string $payload * @return string @@ -141,12 +126,10 @@ protected function refreshRetryUntil($payload) { $payload = json_decode($payload, true); - $jobInstance = unserialize($payload['data']['command']); - - if (method_exists($jobInstance, 'retryUntil')) { - $newRetryUntil = $jobInstance->retryUntil()->timestamp; + $instance = unserialize($payload['data']['command']); - $payload['retryUntil'] = $newRetryUntil; + if (is_object($instance) && method_exists($instance, 'retryUntil')) { + $payload['retryUntil'] = $instance->retryUntil()->timestamp; } return json_encode($payload); From a61cab167c35f465a923737ee6e6fb99cd5fde88 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 5 Jan 2021 09:43:10 -0600 Subject: [PATCH 34/34] version --- src/Illuminate/Foundation/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index c7049c14096c..3dfa37ef701c 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '8.20.1'; + const VERSION = '8.21.0'; /** * The base path for the Laravel installation. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy