From 0bf2a4c3558d10520f89ff92771e64f5167a266b Mon Sep 17 00:00:00 2001 From: zds <49744633+zds-s@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:26:07 +0800 Subject: [PATCH 01/11] fix MailManager::createSesV2Transport typo (#51688) --- src/Illuminate/Mail/MailManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Mail/MailManager.php b/src/Illuminate/Mail/MailManager.php index f821aa933e40..0c54fa23b316 100644 --- a/src/Illuminate/Mail/MailManager.php +++ b/src/Illuminate/Mail/MailManager.php @@ -259,7 +259,7 @@ protected function createSesTransport(array $config) * Create an instance of the Symfony Amazon SES V2 Transport driver. * * @param array $config - * @return \Illuminate\Mail\Transport\Se2VwTransport + * @return \Illuminate\Mail\Transport\SesV2Transport */ protected function createSesV2Transport(array $config) { From 8154eb6e4b9673f332e2c26daf7730e409d443cc Mon Sep 17 00:00:00 2001 From: Faissal Wahabali Date: Mon, 3 Jun 2024 14:02:27 +0100 Subject: [PATCH 02/11] [10.x] Fix collection shift less than one item (#51686) * fix collection shift less than 1 * throw exception earlier * Update Collection.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Collections/Collection.php | 13 ++++++++++--- tests/Support/SupportCollectionTest.php | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index c46fc052f972..6a225dce5c25 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Support\CanBeEscapedWhenCastToString; use Illuminate\Support\Traits\EnumeratesValues; use Illuminate\Support\Traits\Macroable; +use InvalidArgumentException; use stdClass; use Traversable; @@ -1124,17 +1125,23 @@ public function search($value, $strict = false) * * @param int $count * @return static|TValue|null + * + * @throws \InvalidArgumentException */ public function shift($count = 1) { - if ($count === 1) { - return array_shift($this->items); + if ($count < 0) { + throw new InvalidArgumentException('Number of shifted items may not be less than zero.'); } - if ($this->isEmpty()) { + if ($count === 0 || $this->isEmpty()) { return new static; } + if ($count === 1) { + return array_shift($this->items); + } + $results = []; $collectionCount = $this->count(); diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 6eb4f372bf44..8f72a9ca1e5e 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -391,6 +391,17 @@ public function testShiftReturnsAndRemovesFirstXItemsInCollection() $this->assertSame('baz', $data->first()); $this->assertEquals(new Collection(['foo', 'bar', 'baz']), (new Collection(['foo', 'bar', 'baz']))->shift(6)); + + $data = new Collection(['foo', 'bar', 'baz']); + + $this->assertEquals(new Collection([]), $data->shift(0)); + $this->assertEquals(collect(['foo', 'bar', 'baz']), $data); + + $this->expectException('InvalidArgumentException'); + (new Collection(['foo', 'bar', 'baz']))->shift(-1); + + $this->expectException('InvalidArgumentException'); + (new Collection(['foo', 'bar', 'baz']))->shift(-2); } /** From 6de257e066f7193b077564a56e3eb9f57faf505b Mon Sep 17 00:00:00 2001 From: Faissal Wahabali Date: Tue, 4 Jun 2024 14:31:20 +0100 Subject: [PATCH 03/11] [10.x] Turn `Enumerable unless()` $callback parameter optional (#51701) * turn Enumerable unless() parameter optional * nullable parameters declaration --- src/Illuminate/Collections/Enumerable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index 918f64758e66..c9fb24fa1fac 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -338,11 +338,11 @@ public function whenNotEmpty(callable $callback, callable $default = null); * @template TUnlessReturnType * * @param bool $value - * @param (callable($this): TUnlessReturnType) $callback + * @param (callable($this): TUnlessReturnType)|null $callback * @param (callable($this): TUnlessReturnType)|null $default * @return $this|TUnlessReturnType */ - public function unless($value, callable $callback, callable $default = null); + public function unless($value, ?callable $callback = null, ?callable $default = null); /** * Apply the callback unless the collection is empty. From c66290f9656cfca2bea9e7646605fc8e3924b988 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 4 Jun 2024 08:31:47 -0500 Subject: [PATCH 04/11] Revert "[10.x] Turn `Enumerable unless()` $callback parameter optional (#51701)" (#51707) This reverts commit 6de257e066f7193b077564a56e3eb9f57faf505b. --- src/Illuminate/Collections/Enumerable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index c9fb24fa1fac..918f64758e66 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -338,11 +338,11 @@ public function whenNotEmpty(callable $callback, callable $default = null); * @template TUnlessReturnType * * @param bool $value - * @param (callable($this): TUnlessReturnType)|null $callback + * @param (callable($this): TUnlessReturnType) $callback * @param (callable($this): TUnlessReturnType)|null $default * @return $this|TUnlessReturnType */ - public function unless($value, ?callable $callback = null, ?callable $default = null); + public function unless($value, callable $callback, callable $default = null); /** * Apply the callback unless the collection is empty. From 2c6816d697a4362c09c066118addda251b70b98a Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 18 Jun 2024 16:46:35 +0000 Subject: [PATCH 05/11] Update version to v10.48.13 --- 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 c2c651221107..dfb2f3cd12ae 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '10.48.12'; + const VERSION = '10.48.13'; /** * The base path for the Laravel installation. From a7538760e2dfb744e1e6d26bae16d75749f343f2 Mon Sep 17 00:00:00 2001 From: driesvints Date: Tue, 18 Jun 2024 16:47:59 +0000 Subject: [PATCH 06/11] Update CHANGELOG --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb661fe6817..8569c1b840ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Release Notes for 10.x -## [Unreleased](https://github.com/laravel/framework/compare/v10.48.12...10.x) +## [Unreleased](https://github.com/laravel/framework/compare/v10.48.13...10.x) + +## [v10.48.13](https://github.com/laravel/framework/compare/v10.48.12...v10.48.13) - 2024-06-18 + +* [10.x] Fix typo in return comment of createSesTransport method by [@zds-s](https://github.com/zds-s) in https://github.com/laravel/framework/pull/51688 +* [10.x] Fix collection shift less than one item by [@faissaloux](https://github.com/faissaloux) in https://github.com/laravel/framework/pull/51686 +* [10.x] Turn `Enumerable unless()` $callback parameter optional by [@faissaloux](https://github.com/faissaloux) in https://github.com/laravel/framework/pull/51701 +* Revert "[10.x] Turn `Enumerable unless()` $callback parameter optional" by [@taylorotwell](https://github.com/taylorotwell) in https://github.com/laravel/framework/pull/51707 ## [v10.48.12](https://github.com/laravel/framework/compare/v10.48.11...v10.48.12) - 2024-05-28 From d3f16e857ecf542a82cf18cebb0b2c1e56dfccc8 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 19 Jun 2024 01:24:16 +0800 Subject: [PATCH 07/11] [10.x] Fixes unable to call another command as a initialized instance of `Command` class. (#51824) fixes #51822 Signed-off-by: Mior Muhammad Zaki --- src/Illuminate/Console/Command.php | 10 +++-- .../Integration/Console/CallCommandsTest.php | 38 +++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 tests/Integration/Console/CallCommandsTest.php diff --git a/src/Illuminate/Console/Command.php b/src/Illuminate/Console/Command.php index 7e1b3a1ff6ed..1c6d949fd12f 100755 --- a/src/Illuminate/Console/Command.php +++ b/src/Illuminate/Console/Command.php @@ -236,11 +236,13 @@ protected function commandIsolationMutex() */ protected function resolveCommand($command) { - if (! class_exists($command)) { - return $this->getApplication()->find($command); - } + if (is_string($command)) { + if (! class_exists($command)) { + return $this->getApplication()->find($command); + } - $command = $this->laravel->make($command); + $command = $this->laravel->make($command); + } if ($command instanceof SymfonyCommand) { $command->setApplication($this->getApplication()); diff --git a/tests/Integration/Console/CallCommandsTest.php b/tests/Integration/Console/CallCommandsTest.php new file mode 100644 index 000000000000..4724b538aec1 --- /dev/null +++ b/tests/Integration/Console/CallCommandsTest.php @@ -0,0 +1,38 @@ +afterApplicationCreated(function () { + Artisan::command('test:a', function () { + $this->call('view:clear'); + }); + + Artisan::command('test:b', function () { + $this->call(ViewClearCommand::class); + }); + + Artisan::command('test:c', function () { + $this->call($this->laravel->make(ViewClearCommand::class)); + }); + }); + + parent::setUp(); + } + + #[TestWith(['test:a'])] + #[TestWith(['test:b'])] + #[TestWith(['test:c'])] + public function testItCanCallCommands(string $command) + { + $this->artisan($command)->assertSuccessful(); + } +} From 16472d1bce7b7619b3dceadbc2349053855397e6 Mon Sep 17 00:00:00 2001 From: Tonko Mulder Date: Wed, 19 Jun 2024 16:25:05 +0200 Subject: [PATCH 08/11] [10.x] fix handle `shift()` on an empty collection (#51841) * add test for collection shift on a empty collection * fix collection shift when dealing with an empty collection * place the `isEmpty()` check before the count check * update naming and assert the actual values --- src/Illuminate/Collections/Collection.php | 6 +++++- tests/Support/SupportCollectionTest.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 6a225dce5c25..d7369d686591 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -1134,7 +1134,11 @@ public function shift($count = 1) throw new InvalidArgumentException('Number of shifted items may not be less than zero.'); } - if ($count === 0 || $this->isEmpty()) { + if ($this->isEmpty()) { + return null; + } + + if ($count === 0) { return new static; } diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 8f72a9ca1e5e..e1e0a2d89cdb 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -404,6 +404,23 @@ public function testShiftReturnsAndRemovesFirstXItemsInCollection() (new Collection(['foo', 'bar', 'baz']))->shift(-2); } + public function testShiftReturnsNullOnEmptyCollection() + { + $itemFoo = new \stdClass(); + $itemFoo->text = 'f'; + $itemBar = new \stdClass(); + $itemBar->text = 'x'; + + $items = collect([$itemFoo, $itemBar]); + + $foo = $items->shift(); + $bar = $items->shift(); + + $this->assertSame('f', $foo?->text); + $this->assertSame('x', $bar?->text); + $this->assertNull($items->shift()); + } + /** * @dataProvider collectionClassProvider */ From f7ea4e912ce9bacfdb327de4648d07b4c7ee3cb7 Mon Sep 17 00:00:00 2001 From: NickSdot <32384907+NickSdot@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:05:23 +0800 Subject: [PATCH 09/11] [10.x] Ensure`schema:dump` will dump the migrations table only if it exists (#51827) * fix: migrations table must only be dumped on default connection * fix: migrations table must only be dumped on default connection * Style * Use `$this->connection->getSchemaBuilder()->hasTable()` instead of `Config::get()`` * Update SchemaState.php --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Database/Schema/MySqlSchemaState.php | 4 +++- src/Illuminate/Database/Schema/PostgresSchemaState.php | 5 ++++- src/Illuminate/Database/Schema/SchemaState.php | 10 ++++++++++ src/Illuminate/Database/Schema/SqliteSchemaState.php | 4 +++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Schema/MySqlSchemaState.php b/src/Illuminate/Database/Schema/MySqlSchemaState.php index 2514c18bd6c1..5bed2f003974 100644 --- a/src/Illuminate/Database/Schema/MySqlSchemaState.php +++ b/src/Illuminate/Database/Schema/MySqlSchemaState.php @@ -26,7 +26,9 @@ public function dump(Connection $connection, $path) $this->removeAutoIncrementingState($path); - $this->appendMigrationData($path); + if ($this->hasMigrationTable()) { + $this->appendMigrationData($path); + } } /** diff --git a/src/Illuminate/Database/Schema/PostgresSchemaState.php b/src/Illuminate/Database/Schema/PostgresSchemaState.php index b3f9361bc92b..70ccd25b5fd3 100644 --- a/src/Illuminate/Database/Schema/PostgresSchemaState.php +++ b/src/Illuminate/Database/Schema/PostgresSchemaState.php @@ -17,9 +17,12 @@ public function dump(Connection $connection, $path) { $commands = collect([ $this->baseDumpCommand().' --schema-only > '.$path, - $this->baseDumpCommand().' -t '.$this->migrationTable.' --data-only >> '.$path, ]); + if ($this->hasMigrationTable()) { + $commands->push($this->baseDumpCommand().' -t '.$this->migrationTable.' --data-only >> '.$path); + } + $commands->map(function ($command, $path) { $this->makeProcess($command)->mustRun($this->output, array_merge($this->baseVariables($this->connection->getConfig()), [ 'LARAVEL_LOAD_PATH' => $path, diff --git a/src/Illuminate/Database/Schema/SchemaState.php b/src/Illuminate/Database/Schema/SchemaState.php index 58d9c3a438aa..b7fa34c168c9 100644 --- a/src/Illuminate/Database/Schema/SchemaState.php +++ b/src/Illuminate/Database/Schema/SchemaState.php @@ -94,6 +94,16 @@ public function makeProcess(...$arguments) return call_user_func($this->processFactory, ...$arguments); } + /** + * Determine if the current connection has a migration table. + * + * @return bool + */ + public function hasMigrationTable(): bool + { + return $this->connection->getSchemaBuilder()->hasTable($this->migrationTable); + } + /** * Specify the name of the application's migration table. * diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index 10efc7c0aba9..4b66542923e4 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -28,7 +28,9 @@ public function dump(Connection $connection, $path) $this->files->put($path, implode(PHP_EOL, $migrations).PHP_EOL); - $this->appendMigrationData($path); + if ($this->hasMigrationTable()) { + $this->appendMigrationData($path); + } } /** From 27cb4736bb7e60a5311ec73160068dfbcf98336b Mon Sep 17 00:00:00 2001 From: driesvints Date: Fri, 21 Jun 2024 10:06:42 +0000 Subject: [PATCH 10/11] Update version to v10.48.14 --- 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 dfb2f3cd12ae..aab422487c11 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -40,7 +40,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '10.48.13'; + const VERSION = '10.48.14'; /** * The base path for the Laravel installation. From 35f07d3d3ceafc748f6301b5f4520dbd15924e36 Mon Sep 17 00:00:00 2001 From: driesvints Date: Fri, 21 Jun 2024 10:08:05 +0000 Subject: [PATCH 11/11] Update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8569c1b840ca..624faacde463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Release Notes for 10.x -## [Unreleased](https://github.com/laravel/framework/compare/v10.48.13...10.x) +## [Unreleased](https://github.com/laravel/framework/compare/v10.48.14...10.x) + +## [v10.48.14](https://github.com/laravel/framework/compare/v10.48.13...v10.48.14) - 2024-06-21 + +* [10.x] Fixes unable to call another command as a initialized instance of `Command` class by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/framework/pull/51824 +* [10.x] fix handle `shift()` on an empty collection by [@Treggats](https://github.com/Treggats) in https://github.com/laravel/framework/pull/51841 +* [10.x] Ensure`schema:dump` will dump the migrations table only if it exists by [@NickSdot](https://github.com/NickSdot) in https://github.com/laravel/framework/pull/51827 ## [v10.48.13](https://github.com/laravel/framework/compare/v10.48.12...v10.48.13) - 2024-06-18