From 1a146d2c170390def0b017146b21c9f8c21691ce Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 19 Jan 2021 14:24:34 +0100 Subject: [PATCH 01/67] Fix empty email with attachments (#35941) --- src/Illuminate/Mail/Mailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index 2d310a3a00a0..7a11e58f68fc 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -325,7 +325,7 @@ protected function parseView($view) protected function addContent($message, $view, $plain, $raw, $data) { if (isset($view)) { - $message->setBody($this->renderView($view, $data), 'text/html'); + $message->setBody($this->renderView($view, $data) ?: ' ', 'text/html'); } if (isset($plain)) { From 12ed06da14e3fe4257cb1ece91c2d3439cc2d34b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 19 Jan 2021 07:41:17 -0600 Subject: [PATCH 02/67] 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 f58255d51049..30e8e7c358b1 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.12'; + const VERSION = '6.20.13'; /** * The base path for the Laravel installation. From cc526911b5dc830a39a4039828b871dbeca36ea4 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 19 Jan 2021 19:46:10 +0200 Subject: [PATCH 03/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 3ab00165cccc..570c2d5b9317 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.10...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.11...6.x) + + +## [v6.20.11 (2021-01-19)](https://github.com/laravel/framework/compare/v6.20.10...v6.20.11) + +### Fixed +- Limit expected bindings ([#35865](https://github.com/laravel/framework/pull/35865)) ## [v6.20.10 (2021-01-12)](https://github.com/laravel/framework/compare/v6.20.9...v6.20.10) From 19aeb79014b05b76f9e5e016a24f8bd78b59d209 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 19 Jan 2021 19:49:41 +0200 Subject: [PATCH 04/67] [6.x] update changelog --- CHANGELOG-6.x.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 570c2d5b9317..ae2f901c392d 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -3,7 +3,7 @@ ## [Unreleased](https://github.com/laravel/framework/compare/v6.20.11...6.x) -## [v6.20.11 (2021-01-19)](https://github.com/laravel/framework/compare/v6.20.10...v6.20.11) +## [v6.20.11 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.10...v6.20.11) ### Fixed - Limit expected bindings ([#35865](https://github.com/laravel/framework/pull/35865)) From e4be180ad35a378b8e59e4c0236567995851a3f8 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 19 Jan 2021 20:10:30 +0200 Subject: [PATCH 05/67] [6.x] update changelog --- CHANGELOG-6.x.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index ae2f901c392d..00a6d2154eea 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,9 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.11...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.12...6.x) + + +## [v6.20.12 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.11...v6.20.12) ## [v6.20.11 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.10...v6.20.11) From f0dc53f3641b51373cc06e5ca3bcf8549c8186dd Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 19 Jan 2021 20:16:32 +0200 Subject: [PATCH 06/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 00a6d2154eea..42350000b97c 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.12...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.13...6.x) + + +## [v6.20.13 (2021-01-19)](https://github.com/laravel/framework/compare/v6.20.12...v6.20.13) + +### Fixed +- Fixed empty html mail ([#35941](https://github.com/laravel/framework/pull/35941)) ## [v6.20.12 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.11...v6.20.12) From d08fd806337d991ea14e578a9c85b2f6d4ae990e Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Wed, 20 Jan 2021 13:50:36 +0000 Subject: [PATCH 07/67] Fixed type error (#35956) --- src/Illuminate/Http/Concerns/InteractsWithContentTypes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php b/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php index be760a2619d9..25d6ec1e9986 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php +++ b/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php @@ -31,7 +31,7 @@ public static function matchesType($actual, $type) */ public function isJson() { - return Str::contains($this->header('CONTENT_TYPE'), ['/json', '+json']); + return Str::contains($this->header('CONTENT_TYPE') ?? '', ['/json', '+json']); } /** From 9d3752ca5f29c4cb1c0384fb01847820b6ac492c Mon Sep 17 00:00:00 2001 From: Kane Cohen Date: Thu, 21 Jan 2021 08:44:52 +0000 Subject: [PATCH 08/67] Limit expected bindingx v2. --- src/Illuminate/Database/Query/Builder.php | 25 +++++++++++++++------ tests/Database/DatabaseQueryBuilderTest.php | 5 +++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 83416d83be02..c8d47e621495 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -307,6 +307,17 @@ public function fromRaw($expression, $bindings = []) return $this; } + /** + * Returns scalar type value from an unknown type of input. + * + * @param mixed $value + * @return mixed + */ + protected function scalarValue($value) + { + return is_array($value) ? head(Arr::flatten($value)) : $value; + } + /** * Creates a subquery and parse it. * @@ -698,7 +709,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' ); if (! $value instanceof Expression) { - $this->addBinding(is_array($value) ? head($value) : $value, 'where'); + $this->addBinding($this->scalarValue($value), 'where'); } return $this; @@ -1043,7 +1054,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa $this->wheres[] = compact('type', 'column', 'values', 'boolean', 'not'); - $this->addBinding(array_slice($this->cleanBindings($values), 0, 2), 'where'); + $this->addBinding(array_slice($this->cleanBindings(Arr::flatten($values)), 0, 2), 'where'); return $this; } @@ -1111,7 +1122,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = is_array($value) ? head($value) : $value; + $value = $this->scalarValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('Y-m-d'); @@ -1152,7 +1163,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = is_array($value) ? head($value) : $value; + $value = $this->scalarValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('H:i:s'); @@ -1238,7 +1249,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = is_array($value) ? head($value) : $value; + $value = $this->scalarValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('m'); @@ -1593,7 +1604,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) { - $this->addBinding((int) $value); + $this->addBinding((int) $this->scalarValue($value)); } return $this; @@ -1742,7 +1753,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and $this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) { - $this->addBinding(is_array($value) ? head($value) : $value, 'having'); + $this->addBinding($this->scalarValue($value), 'having'); } return $this; diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index f7d20c532223..781bc637b2a4 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -319,6 +319,11 @@ public function testWheresWithArrayValue() $builder->select('*')->from('users')->where('id', '<>', [12, 30]); $this->assertSame('select * from "users" where "id" <> ?', $builder->toSql()); $this->assertEquals([0 => 12], $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->where('id', '=', [[12, 30]]); + $this->assertSame('select * from "users" where "id" = ?', $builder->toSql()); + $this->assertEquals([0 => 12], $builder->getBindings()); } public function testMySqlWrappingProtectsQuotationMarks() From dbbb1c1c8a1fa0a51677b5a74fcfe0e2561ced91 Mon Sep 17 00:00:00 2001 From: Kane Cohen Date: Thu, 21 Jan 2021 10:48:50 +0000 Subject: [PATCH 09/67] Update whereDay and whereYear to clean value. --- src/Illuminate/Database/Query/Builder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index c8d47e621495..85679e9472c0 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -1204,7 +1204,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = is_array($value) ? head($value) : $value; + $value = $this->scalarValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('d'); @@ -1294,7 +1294,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = is_array($value) ? head($value) : $value; + $value = $this->scalarValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('Y'); From c6b8168e6cbbe339fdc3af5ccdded545779965df Mon Sep 17 00:00:00 2001 From: Kane Cohen Date: Thu, 21 Jan 2021 12:08:38 +0000 Subject: [PATCH 10/67] Add limit bindings for having between + tests. --- src/Illuminate/Database/Query/Builder.php | 2 +- tests/Database/DatabaseQueryBuilderTest.php | 23 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 85679e9472c0..8ab17d32b960 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -1791,7 +1791,7 @@ public function havingBetween($column, array $values, $boolean = 'and', $not = f $this->havings[] = compact('type', 'column', 'values', 'boolean', 'not'); - $this->addBinding($this->cleanBindings($values), 'having'); + $this->addBinding(array_slice($this->cleanBindings(Arr::flatten($values)), 0, 2), 'having'); return $this; } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 781bc637b2a4..8607434fea1a 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -654,6 +654,16 @@ public function testWhereBetweens() $this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql()); $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->whereBetween('id', [[1, 2, 3]]); + $this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql()); + $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->whereBetween('id', [[1], [2, 3]]); + $this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql()); + $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); + $builder = $this->getBuilder(); $builder->select('*')->from('users')->whereNotBetween('id', [1, 2]); $this->assertSame('select * from "users" where "id" not between ? and ?', $builder->toSql()); @@ -1172,10 +1182,19 @@ public function testHavings() $builder = $this->getBuilder(); $builder->select(['category', new Raw('count(*) as "total"')])->from('item')->where('department', '=', 'popular')->groupBy('category')->having('total', '>', 3); $this->assertSame('select "category", count(*) as "total" from "item" where "department" = ? group by "category" having "total" > ?', $builder->toSql()); + } + public function testHavingBetweens() + { $builder = $this->getBuilder(); - $builder->select('*')->from('users')->havingBetween('last_login_date', ['2018-11-16', '2018-12-16']); - $this->assertSame('select * from "users" having "last_login_date" between ? and ?', $builder->toSql()); + $builder->select('*')->from('users')->havingBetween('id', [1, 2, 3]); + $this->assertSame('select * from "users" having "id" between ? and ?', $builder->toSql()); + $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->havingBetween('id', [[1, 2], [3, 4]]); + $this->assertSame('select * from "users" having "id" between ? and ?', $builder->toSql()); + $this->assertEquals([0 => 1, 1 => 2], $builder->getBindings()); } public function testHavingShortcut() From 006873df411d28bfd03fea5e7f91a2afe3918498 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 21 Jan 2021 08:07:23 -0600 Subject: [PATCH 11/67] formatting --- src/Illuminate/Database/Query/Builder.php | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 8ab17d32b960..c762e8525605 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -307,17 +307,6 @@ public function fromRaw($expression, $bindings = []) return $this; } - /** - * Returns scalar type value from an unknown type of input. - * - * @param mixed $value - * @return mixed - */ - protected function scalarValue($value) - { - return is_array($value) ? head(Arr::flatten($value)) : $value; - } - /** * Creates a subquery and parse it. * @@ -709,7 +698,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' ); if (! $value instanceof Expression) { - $this->addBinding($this->scalarValue($value), 'where'); + $this->addBinding($this->flattenValue($value), 'where'); } return $this; @@ -1122,7 +1111,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = $this->scalarValue($value); + $value = $this->flattenValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('Y-m-d'); @@ -1163,7 +1152,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = $this->scalarValue($value); + $value = $this->flattenValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('H:i:s'); @@ -1204,7 +1193,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = $this->scalarValue($value); + $value = $this->flattenValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('d'); @@ -1249,7 +1238,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = $this->scalarValue($value); + $value = $this->flattenValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('m'); @@ -1294,7 +1283,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); - $value = $this->scalarValue($value); + $value = $this->flattenValue($value); if ($value instanceof DateTimeInterface) { $value = $value->format('Y'); @@ -1604,7 +1593,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) { - $this->addBinding((int) $this->scalarValue($value)); + $this->addBinding((int) $this->flattenValue($value)); } return $this; @@ -1753,7 +1742,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and $this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) { - $this->addBinding($this->scalarValue($value), 'having'); + $this->addBinding($this->flattenValue($value), 'having'); } return $this; @@ -2969,6 +2958,17 @@ protected function cleanBindings(array $bindings) })); } + /** + * Get a scalar type value from an unknown type of input. + * + * @param mixed $value + * @return mixed + */ + protected function flattenValue($value) + { + return is_array($value) ? head(Arr::flatten($value)) : $value; + } + /** * Get the default key name of the table. * From 3464d0232cb75aeadb7b4483f788c1d1a30221d4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 21 Jan 2021 08:10:27 -0600 Subject: [PATCH 12/67] 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 30e8e7c358b1..35348d53f62b 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.13'; + const VERSION = '6.20.14'; /** * The base path for the Laravel installation. From 6e79268aa8b0d242ab78a54bce304f0cc7735876 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Mon, 25 Jan 2021 16:20:15 +0000 Subject: [PATCH 13/67] Fix PHP 8.0 showing as 8 (#36039) --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2a186904407..19e95cff1f99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: true matrix: - php: [7.2, 7.3, 7.4, 8.0] + php: ['7.2', '7.3', '7.4', '8.0'] stability: [prefer-lowest, prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} @@ -78,7 +78,7 @@ jobs: strategy: fail-fast: true matrix: - php: [7.2, 7.3, 7.4, 8.0] + php: ['7.2', '7.3', '7.4', '8.0'] stability: [prefer-lowest, prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - Windows From fdf46c336f90b1c7eb94ae6bda4202aa0ea64600 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 25 Jan 2021 18:07:55 +0100 Subject: [PATCH 14/67] [6.x] Backport of Pipe through render and report exception methods (#36037) * Pipe through render and report exception methods (#36032) * Fix method_exists call * Re-add facade --- .../View/Engines/CompilerEngine.php | 4 +- src/Illuminate/View/ViewException.php | 37 +++++++++++++++++++ .../View/RenderableViewExceptionTest.php | 36 ++++++++++++++++++ .../templates/renderable-exception.blade.php | 3 ++ tests/View/fixtures/nested/basic.php | 1 - 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 src/Illuminate/View/ViewException.php create mode 100644 tests/Integration/View/RenderableViewExceptionTest.php create mode 100644 tests/Integration/View/templates/renderable-exception.blade.php diff --git a/src/Illuminate/View/Engines/CompilerEngine.php b/src/Illuminate/View/Engines/CompilerEngine.php index 03717bad0b51..cf6dac70e8a1 100755 --- a/src/Illuminate/View/Engines/CompilerEngine.php +++ b/src/Illuminate/View/Engines/CompilerEngine.php @@ -2,9 +2,9 @@ namespace Illuminate\View\Engines; -use ErrorException; use Exception; use Illuminate\View\Compilers\CompilerInterface; +use Illuminate\View\ViewException; class CompilerEngine extends PhpEngine { @@ -74,7 +74,7 @@ public function get($path, array $data = []) */ protected function handleViewException(Exception $e, $obLevel) { - $e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); + $e = new ViewException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); parent::handleViewException($e, $obLevel); } diff --git a/src/Illuminate/View/ViewException.php b/src/Illuminate/View/ViewException.php new file mode 100644 index 000000000000..9c9463bc28ac --- /dev/null +++ b/src/Illuminate/View/ViewException.php @@ -0,0 +1,37 @@ +getPrevious(); + + if ($exception && method_exists($exception, 'report')) { + $exception->report(); + } + } + + /** + * Render the exception into an HTTP response. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function render($request) + { + $exception = $this->getPrevious(); + + if ($exception && method_exists($exception, 'render')) { + return $exception->render($request); + } + } +} diff --git a/tests/Integration/View/RenderableViewExceptionTest.php b/tests/Integration/View/RenderableViewExceptionTest.php new file mode 100644 index 000000000000..93c91cb31387 --- /dev/null +++ b/tests/Integration/View/RenderableViewExceptionTest.php @@ -0,0 +1,36 @@ +get('/'); + + $response->assertSee('This is a renderable exception.'); + } + + protected function getEnvironmentSetUp($app) + { + $app['config']->set('view.paths', [__DIR__.'/templates']); + } +} + +class RenderableException extends Exception +{ + public function render($request) + { + return new Response('This is a renderable exception.'); + } +} diff --git a/tests/Integration/View/templates/renderable-exception.blade.php b/tests/Integration/View/templates/renderable-exception.blade.php new file mode 100644 index 000000000000..28649eefa7f9 --- /dev/null +++ b/tests/Integration/View/templates/renderable-exception.blade.php @@ -0,0 +1,3 @@ +@php + throw new Illuminate\Tests\Integration\View\RenderableException; +@endphp diff --git a/tests/View/fixtures/nested/basic.php b/tests/View/fixtures/nested/basic.php index 557db03de997..e69de29bb2d1 100755 --- a/tests/View/fixtures/nested/basic.php +++ b/tests/View/fixtures/nested/basic.php @@ -1 +0,0 @@ -Hello World From b42c2d845cdd827ac5a53cacf16af4a0b5dd8be1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 26 Jan 2021 08:39:47 -0600 Subject: [PATCH 15/67] 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 35348d53f62b..648a0cd2f21a 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.14'; + const VERSION = '6.20.15'; /** * The base path for the Laravel installation. From 9d7f75e0b3c61a07987aad87af801688e5011b98 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 26 Jan 2021 18:15:42 +0100 Subject: [PATCH 16/67] Typecast page number as integer (#36055) --- src/Illuminate/Pagination/AbstractPaginator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Pagination/AbstractPaginator.php b/src/Illuminate/Pagination/AbstractPaginator.php index e09ec3b2c89c..5fefab34ce06 100644 --- a/src/Illuminate/Pagination/AbstractPaginator.php +++ b/src/Illuminate/Pagination/AbstractPaginator.php @@ -446,7 +446,7 @@ public static function currentPathResolver(Closure $resolver) public static function resolveCurrentPage($pageName = 'page', $default = 1) { if (isset(static::$currentPageResolver)) { - return call_user_func(static::$currentPageResolver, $pageName); + return (int) call_user_func(static::$currentPageResolver, $pageName); } return $default; From c0140c4cc54ab40f73b10d9368c7551c88fc1ba3 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 27 Jan 2021 23:01:27 +0200 Subject: [PATCH 17/67] [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 42350000b97c..8e34966a1e95 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.13...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.14...6.x) + + +## [v6.20.14 (2021-01-21)](https://github.com/laravel/framework/compare/v6.20.13...v6.20.14) + +### Fixed +- Fixed type error in `Illuminate\Http\Concerns\InteractsWithContentTypes::isJson()` ([#35956](https://github.com/laravel/framework/pull/35956)) +- Limit expected bindings ([#35972](https://github.com/laravel/framework/pull/35972), [006873d](https://github.com/laravel/framework/commit/006873df411d28bfd03fea5e7f91a2afe3918498)) ## [v6.20.13 (2021-01-19)](https://github.com/laravel/framework/compare/v6.20.12...v6.20.13) From 0966a30d56a697426bb64babcddc32a19c44a639 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 27 Jan 2021 23:21:23 +0200 Subject: [PATCH 18/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8e34966a1e95..71992b608e31 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.14...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.15...6.x) + + +## [v6.20.15 (2021-01-26)](https://github.com/laravel/framework/compare/v6.20.14...v6.20.15) + +### Changed +- Pipe new through render and report exception methods ([#36037](https://github.com/laravel/framework/pull/36037)) ## [v6.20.14 (2021-01-21)](https://github.com/laravel/framework/compare/v6.20.13...v6.20.14) From 818232948bd04b2601b58d4998955508f5064716 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 1 Feb 2021 15:20:21 +0100 Subject: [PATCH 19/67] [6.x] Fix report method for ViewException (#36110) * Fix report method for ViewException * Update ViewException.php * Apply fixes from StyleCI (#36111) --- .../Console/stubs/exception-render-report.stub | 2 +- .../Foundation/Console/stubs/exception-report.stub | 2 +- src/Illuminate/View/ViewException.php | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub b/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub index 712a40789e76..4d1070c2f687 100644 --- a/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub +++ b/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub @@ -9,7 +9,7 @@ class DummyClass extends Exception /** * Report the exception. * - * @return void + * @return bool|null */ public function report() { diff --git a/src/Illuminate/Foundation/Console/stubs/exception-report.stub b/src/Illuminate/Foundation/Console/stubs/exception-report.stub index 8db5c4f3c2b2..643149863e91 100644 --- a/src/Illuminate/Foundation/Console/stubs/exception-report.stub +++ b/src/Illuminate/Foundation/Console/stubs/exception-report.stub @@ -9,7 +9,7 @@ class DummyClass extends Exception /** * Report the exception. * - * @return void + * @return bool|null */ public function report() { diff --git a/src/Illuminate/View/ViewException.php b/src/Illuminate/View/ViewException.php index 9c9463bc28ac..e6797a29a1e7 100644 --- a/src/Illuminate/View/ViewException.php +++ b/src/Illuminate/View/ViewException.php @@ -3,21 +3,25 @@ namespace Illuminate\View; use ErrorException; +use Illuminate\Container\Container; +use Illuminate\Support\Reflector; class ViewException extends ErrorException { /** * Report the exception. * - * @return void + * @return bool|null */ public function report() { $exception = $this->getPrevious(); - if ($exception && method_exists($exception, 'report')) { - $exception->report(); + if (Reflector::isCallable($reportCallable = [$exception, 'report'])) { + return Container::getInstance()->call($reportCallable); } + + return false; } /** From 3aa9657c9519b2ab73ab93f3917f750a029bfbcc Mon Sep 17 00:00:00 2001 From: Zing Date: Mon, 1 Feb 2021 22:54:22 +0800 Subject: [PATCH 20/67] [6.x] Fix the return type of spop for phpredis (#36106) * PhpRedis return value of spop compatibility * fix style * use func_get_args() instead of [$key, $count] * Update PhpRedisConnection.php Co-authored-by: Taylor Otwell --- .../Redis/Connections/PhpRedisConnection.php | 2 +- tests/Redis/RedisConnectionTest.php | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Redis/Connections/PhpRedisConnection.php b/src/Illuminate/Redis/Connections/PhpRedisConnection.php index 0950ec97cdcb..0c4015df9880 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisConnection.php @@ -197,7 +197,7 @@ public function brpop(...$arguments) */ public function spop($key, $count = 1) { - return $this->command('spop', [$key, $count]); + return $this->command('spop', func_get_args()); } /** diff --git a/tests/Redis/RedisConnectionTest.php b/tests/Redis/RedisConnectionTest.php index 5326a09dd608..e3a04e6db591 100644 --- a/tests/Redis/RedisConnectionTest.php +++ b/tests/Redis/RedisConnectionTest.php @@ -690,6 +690,33 @@ public function testItSscansForKeys() } } + public function testItSPopsForKeys() + { + foreach ($this->connections() as $redis) { + $members = ['test:spop:1', 'test:spop:2', 'test:spop:3', 'test:spop:4']; + + foreach ($members as $member) { + $redis->sadd('set', $member); + } + + $result = $redis->spop('set'); + $this->assertIsNotArray($result); + $this->assertContains($result, $members); + + $result = $redis->spop('set', 1); + + $this->assertIsArray($result); + $this->assertCount(1, $result); + + $result = $redis->spop('set', 2); + + $this->assertIsArray($result); + $this->assertCount(2, $result); + + $redis->flushAll(); + } + } + public function testPhpRedisScanOption() { foreach ($this->connections() as $redis) { From 806082fb559fe595cb17cd6aa8571f03ed287814 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Feb 2021 07:50:12 -0600 Subject: [PATCH 21/67] 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 648a0cd2f21a..236cd15d06f3 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.15'; + const VERSION = '6.20.16'; /** * The base path for the Laravel installation. From 7b99b40e2e190ed44b979f4bc647909c3960fcf0 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Thu, 4 Feb 2021 22:22:33 +0200 Subject: [PATCH 22/67] [6.x] update changelog --- CHANGELOG-6.x.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 71992b608e31..8b7d54876d3f 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,16 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.15...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.16...6.x) + + +## [v6.20.15 (2021-02-02)](https://github.com/laravel/framework/compare/v6.20.15...v6.20.16) + +### Fixed +- Fixed `Illuminate\View\ViewException::report()` ([#36110](https://github.com/laravel/framework/pull/36110)) +- Fixed `Illuminate\Redis\Connections\PhpRedisConnection::spop()` ([#36106](https://github.com/laravel/framework/pull/36106)) + +### Changed +- Typecast page number as integer in `Illuminate\Pagination\AbstractPaginator::resolveCurrentPage()` ([#36055](https://github.com/laravel/framework/pull/36055)) ## [v6.20.15 (2021-01-26)](https://github.com/laravel/framework/compare/v6.20.14...v6.20.15) From d7e3b9b82b20b3a3440cbcb8a8f60914fad33812 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Thu, 4 Feb 2021 22:24:52 +0200 Subject: [PATCH 23/67] [6.x] update changelog --- CHANGELOG-6.x.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8b7d54876d3f..ee1b7ced29b4 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -3,7 +3,7 @@ ## [Unreleased](https://github.com/laravel/framework/compare/v6.20.16...6.x) -## [v6.20.15 (2021-02-02)](https://github.com/laravel/framework/compare/v6.20.15...v6.20.16) +## [v6.20.16 (2021-02-02)](https://github.com/laravel/framework/compare/v6.20.15...v6.20.16) ### Fixed - Fixed `Illuminate\View\ViewException::report()` ([#36110](https://github.com/laravel/framework/pull/36110)) From a5e5afb61c1bd4231b3190bc1bdd9d8a19eb57da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Mon, 8 Feb 2021 20:49:57 +0100 Subject: [PATCH 24/67] feat: add query log methods to the DB facade (#36188) --- src/Illuminate/Support/Facades/DB.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Illuminate/Support/Facades/DB.php b/src/Illuminate/Support/Facades/DB.php index a249b4a099b4..bcbe62ced0cc 100755 --- a/src/Illuminate/Support/Facades/DB.php +++ b/src/Illuminate/Support/Facades/DB.php @@ -24,6 +24,11 @@ * @method static int transactionLevel() * @method static array pretend(\Closure $callback) * @method static void listen(\Closure $callback) + * @method static void enableQueryLog() + * @method static void disableQueryLog() + * @method static bool logging() + * @method static array getQueryLog() + * @method static void flushQueryLog() * * @see \Illuminate\Database\DatabaseManager * @see \Illuminate\Database\Connection From d5ffd8efdd04b11a2b1199cc7f2148337418191f Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 12 Feb 2021 22:02:52 +0100 Subject: [PATCH 25/67] Remove problem matchers (#36246) --- .github/workflows/tests.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 19e95cff1f99..476648be81cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,9 +48,6 @@ jobs: tools: composer:v2 coverage: none - - name: Setup problem matchers - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Set Minimum Guzzle Version uses: nick-invision/retry@v1 with: @@ -100,9 +97,6 @@ jobs: tools: composer:v2 coverage: none - - name: Setup problem matchers - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Set Minimum Guzzle Version uses: nick-invision/retry@v1 with: From 55d10a8138dbb86850b82614f34497d30403db1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Wed, 24 Feb 2021 15:50:12 +0200 Subject: [PATCH 26/67] When using managed PostgreSQL instances on DigitalOcean every now and then this pops out. After seeing #35744, #35790 and others decided to fix this. (#36373) PDOException: SQLSTATE[08006] [7] could not translate host name "private-xxx-do-user-0.a.db.ondigitalocean.com" to address: Temporary failure in name resolution --- 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 07630c590d5c..1ecfc96140f4 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -49,6 +49,7 @@ protected function causedByLostConnection(Throwable $e) '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.', + 'Temporary failure in name resolution', ]); } } From d0e4731e92ca88f4a78fe9e0c2c426a3e8c063c8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Mar 2021 08:28:26 -0600 Subject: [PATCH 27/67] patch release --- 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 236cd15d06f3..264e0deba796 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.16'; + const VERSION = '6.20.17'; /** * The base path for the Laravel installation. From 3b1fa1ae2ccd64547d27236945dfe454ee9a23e2 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 3 Mar 2021 21:15:47 +0200 Subject: [PATCH 28/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index ee1b7ced29b4..5fd976698b85 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.16...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.17...6.x) + + +## [v6.20.17 (2021-03-02)](https://github.com/laravel/framework/compare/v6.20.16...v6.20.17) + +### Added +- Added new line to `DetectsLostConnections` ([#36373](https://github.com/laravel/framework/pull/36373)) ## [v6.20.16 (2021-02-02)](https://github.com/laravel/framework/compare/v6.20.15...v6.20.16) From 448662c91540e237b846507fdf4cf22c7f8d59b5 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 4 Mar 2021 13:51:23 +0100 Subject: [PATCH 29/67] Use ubuntu-18.04 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 476648be81cc..c7b91b6fe781 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: jobs: linux_tests: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 services: memcached: From 18daf4619de068cf106ef49c947087d2b655d67c Mon Sep 17 00:00:00 2001 From: Pat Gagnon-Renaud Date: Fri, 5 Mar 2021 09:40:56 -0500 Subject: [PATCH 30/67] Delete existing links that are broken (#36470) When a link exists but is broken, `file_exists($link)` return false. And when `symlink($link, $target)` is called on a broken link, a PHP Warning is returned and the link is not updated. To fix this, we add an additional check using `is_link($link)` (which return true, even if the link is broken) to detect and delete broken links. --- src/Illuminate/Foundation/Console/StorageLinkCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Foundation/Console/StorageLinkCommand.php b/src/Illuminate/Foundation/Console/StorageLinkCommand.php index 11e5c148c1ce..82b461598338 100644 --- a/src/Illuminate/Foundation/Console/StorageLinkCommand.php +++ b/src/Illuminate/Foundation/Console/StorageLinkCommand.php @@ -31,6 +31,10 @@ public function handle() return $this->error('The "public/storage" directory already exists.'); } + if (is_link(public_path('storage'))) { + $this->laravel->make('files')->delete(public_path('storage')); + } + $this->laravel->make('files')->link( storage_path('app/public'), public_path('storage') ); From c5fa6935c731405f9e4edd531203ce094ea43e65 Mon Sep 17 00:00:00 2001 From: Oisin O'Neill Date: Sun, 7 Mar 2021 20:26:06 +0000 Subject: [PATCH 31/67] [6.x] Update changelog for v6.18.27 with upgrade info around cookies (#36490) * Update changelog for v6.18.27 with upgrade info around cookies After this this change any existing cookies will be invalid (which may have implications for some apps) * Update CHANGELOG-6.x.md * Update CHANGELOG-6.x.md Co-authored-by: Taylor Otwell --- CHANGELOG-6.x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 5fd976698b85..860012f0bd0a 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -259,6 +259,8 @@ ### Changed - Improve cookie encryption ([#33662](https://github.com/laravel/framework/pull/33662)) +This change will invalidate all existing cookies. Please see [this security bulletin](https://blog.laravel.com/laravel-cookie-security-releases) for more information. + ## [v6.18.26 (2020-07-21)](https://github.com/laravel/framework/compare/v6.18.25...v6.18.26) From 3f5af8d446564e685207c3296567d8b52dc2be51 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Mon, 8 Mar 2021 23:53:00 +1000 Subject: [PATCH 32/67] [6.x] Fix validator treating null as true for (required|exclude)_(if|unless) due to loose in_array() check (#36504) * Fix required_if treating true as null * Fix required_unless treating true as null * Fix exclude_if treating true as null * Fix exclude_unless treating true as null --- .../Concerns/ValidatesAttributes.php | 8 +-- tests/Validation/ValidationValidatorTest.php | 66 +++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 84e0964ba147..13fe1a648108 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1422,7 +1422,7 @@ public function validateRequiredIf($attribute, $value, $parameters) [$values, $other] = $this->prepareValuesAndOther($parameters); - if (in_array($other, $values)) { + if (in_array($other, $values, is_bool($other))) { return $this->validateRequired($attribute, $value); } @@ -1443,7 +1443,7 @@ public function validateExcludeIf($attribute, $value, $parameters) [$values, $other] = $this->prepareValuesAndOther($parameters); - return ! in_array($other, $values); + return ! in_array($other, $values, is_bool($other)); } /** @@ -1460,7 +1460,7 @@ public function validateExcludeUnless($attribute, $value, $parameters) [$values, $other] = $this->prepareValuesAndOther($parameters); - return in_array($other, $values); + return in_array($other, $values, is_bool($other)); } /** @@ -1515,7 +1515,7 @@ public function validateRequiredUnless($attribute, $value, $parameters) [$values, $other] = $this->prepareValuesAndOther($parameters); - if (! in_array($other, $values)) { + if (! in_array($other, $values, is_bool($other))) { return $this->validateRequired($attribute, $value); } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index a176ce42a055..4ac71213c984 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1056,10 +1056,34 @@ public function testRequiredIf() $v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,false']); $this->assertTrue($v->passes()); + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,null']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => 0], ['bar' => 'required_if:foo,0']); + $this->assertTrue($v->fails()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => '0'], ['bar' => 'required_if:foo,0']); + $this->assertTrue($v->fails()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => 1], ['bar' => 'required_if:foo,1']); + $this->assertTrue($v->fails()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => '1'], ['bar' => 'required_if:foo,1']); + $this->assertTrue($v->fails()); + $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,true']); $this->assertTrue($v->fails()); + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => false], ['bar' => 'required_if:foo,false']); + $this->assertTrue($v->fails()); + // error message when passed multiple values (required_if:foo,bar,baz) $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); @@ -1098,6 +1122,26 @@ public function testRequiredUnless() $v = new Validator($trans, ['foo' => false], ['bar' => 'required_unless:foo,true']); $this->assertTrue($v->fails()); + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => true], ['bar' => 'required_unless:foo,null']); + $this->assertTrue($v->fails()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => '0'], ['bar' => 'required_unless:foo,0']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => 0], ['bar' => 'required_unless:foo,0']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => '1'], ['bar' => 'required_unless:foo,1']); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => 1], ['bar' => 'required_unless:foo,1']); + $this->assertTrue($v->passes()); + // error message when passed multiple values (required_unless:foo,bar,baz) $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.required_unless' => 'The :attribute field is required unless :other is in :values.'], 'en'); @@ -5074,6 +5118,20 @@ public function providesPassingExcludeIfData() 'has_appointment' => false, ], ], + [ + [ + 'has_appointment' => ['nullable', 'bool'], + 'appointment_date' => ['exclude_if:has_appointment,null', 'required', 'date'], + ], + [ + 'has_appointment' => true, + 'appointment_date' => '2021-03-08', + ], + [ + 'has_appointment' => true, + 'appointment_date' => '2021-03-08', + ], + ], [ [ 'has_appointment' => ['required', 'bool'], @@ -5408,6 +5466,14 @@ public function testExcludeUnless() ); $this->assertTrue($validator->fails()); $this->assertSame(['mouse' => ['validation.required']], $validator->messages()->toArray()); + + $validator = new Validator( + $this->getIlluminateArrayTranslator(), + ['foo' => true, 'bar' => 'baz'], + ['foo' => 'nullable', 'bar' => 'exclude_unless:foo,null'] + ); + $this->assertTrue($validator->passes()); + $this->assertSame(['foo' => true], $validator->validated()); } public function testExcludeValuesAreReallyRemoved() From 784f8ff1469a0bb288600d2bb9e02541c8e38a8d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 9 Mar 2021 09:01:58 -0600 Subject: [PATCH 33/67] patch --- 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 264e0deba796..1f46747dbfbd 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.17'; + const VERSION = '6.20.18'; /** * The base path for the Laravel installation. From bbb6b97c48a22a13fc1c8cdae157ae6c42c9d07f Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 9 Mar 2021 20:09:54 +0200 Subject: [PATCH 34/67] [6.x] update changelog --- CHANGELOG-6.x.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 860012f0bd0a..b041da96c128 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,15 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.17...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.18...6.x) + + +## [v6.20.18 (2021-03-09)](https://github.com/laravel/framework/compare/v6.20.17...v6.20.18) + +### Fixed +- Fix validator treating null as true for (required|exclude)_(if|unless) due to loose `in_array()` check ([#36504](https://github.com/laravel/framework/pull/36504)) + +### Changed +- Delete existing links that are broken in `Illuminate\Foundation\Console\StorageLinkCommand` ([#36470](https://github.com/laravel/framework/pull/36470)) ## [v6.20.17 (2021-03-02)](https://github.com/laravel/framework/compare/v6.20.16...v6.20.17) From 61db3ef0e82b0ff5170100e2ea5198a195ac2743 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 11 Mar 2021 17:23:18 +0100 Subject: [PATCH 35/67] Update to ubuntu-20.04 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7b91b6fe781..1a81af4975b9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ on: jobs: linux_tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 services: memcached: From be86b91ca8812a2564cba71f859ebf410ca1f571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Fri, 12 Mar 2021 14:52:50 +0100 Subject: [PATCH 36/67] [6.x] add make method to App facade (#36574) --- src/Illuminate/Support/Facades/App.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Support/Facades/App.php b/src/Illuminate/Support/Facades/App.php index 67e0b4c233e4..0bc5b34254d3 100755 --- a/src/Illuminate/Support/Facades/App.php +++ b/src/Illuminate/Support/Facades/App.php @@ -19,6 +19,7 @@ * @method static \Illuminate\Support\ServiceProvider register(\Illuminate\Support\ServiceProvider|string $provider, bool $force = false) * @method static void registerDeferredProvider(string $provider, string $service = null) * @method static \Illuminate\Support\ServiceProvider resolveProvider(string $provider) + * @method static mixed make($abstract, array $parameters = []) * @method static void boot() * @method static void booting(callable $callback) * @method static void booted(callable $callback) From a69f15d30522eb3c1db5786c6df8a6d4f87bd0a3 Mon Sep 17 00:00:00 2001 From: Markus Machatschek Date: Mon, 15 Mar 2021 14:32:05 +0100 Subject: [PATCH 37/67] Add ssl broken pipe as lost connection error (#36601) --- 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 1ecfc96140f4..a0bad6718017 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -50,6 +50,7 @@ protected function causedByLostConnection(Throwable $e) 'SSL: Connection timed out', 'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', 'Temporary failure in name resolution', + 'SSL: Broken pipe', ]); } } From c25308a00c7bbd38401a6254ab403146da9cfd69 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 16 Mar 2021 09:18:55 -0500 Subject: [PATCH 38/67] 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 1f46747dbfbd..5fa3b2bed350 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.18'; + const VERSION = '6.20.19'; /** * The base path for the Laravel installation. From d3df83a537cfddbbb5df79a6b318d2053b44b700 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 16 Mar 2021 19:21:03 +0200 Subject: [PATCH 39/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index b041da96c128..226fdd550d8a 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.18...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.19...6.x) + + +## [v6.20.19 (2021-03-16)](https://github.com/laravel/framework/compare/v6.20.18...v6.20.19) + +### Added +- Added broken pipe exception as lost connection error ([#36601](https://github.com/laravel/framework/pull/36601)) ## [v6.20.18 (2021-03-09)](https://github.com/laravel/framework/compare/v6.20.17...v6.20.18) From 5df09b142c0c0effb643d206c38cd06ed4e33a30 Mon Sep 17 00:00:00 2001 From: Michel Bardelmeijer Date: Fri, 19 Mar 2021 15:00:44 +0100 Subject: [PATCH 40/67] Add WSREP communication link failure for lost connection detection (#36668) --- 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 a0bad6718017..191eefedc891 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -51,6 +51,7 @@ protected function causedByLostConnection(Throwable $e) 'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', 'Temporary failure in name resolution', 'SSL: Broken pipe', + 'SQLSTATE[08S01]: Communication link failure', ]); } } From 1ac5370b6cfae469be49c14586c64fcda523aef9 Mon Sep 17 00:00:00 2001 From: Chris Gooding Date: Fri, 19 Mar 2021 14:02:08 +0000 Subject: [PATCH 41/67] Fixes the issue when using cache:clear with PhpRedis and a clustered Redis instance, by updating the PhpRedisConnection flushdb method to use the already open/configured clients. (#36665) --- .../Redis/Connections/PhpRedisConnection.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Illuminate/Redis/Connections/PhpRedisConnection.php b/src/Illuminate/Redis/Connections/PhpRedisConnection.php index 0c4015df9880..7e9af99ff29e 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisConnection.php @@ -484,14 +484,8 @@ public function flushdb() return $this->command('flushdb'); } - foreach ($this->client->_masters() as [$host, $port]) { - $redis = tap(new Redis)->connect($host, $port); - - if (isset($this->config['password']) && ! empty($this->config['password'])) { - $redis->auth($this->config['password']); - } - - $redis->flushDb(); + foreach ($this->client->_masters() as $master) { + $this->client->flushDb($master); } } From 664a9432bcceb67871c5c9252f920d28f21dfc23 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Mar 2021 08:12:22 -0700 Subject: [PATCH 42/67] patch --- 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 5fa3b2bed350..4e4d6c1840d3 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.19'; + const VERSION = '6.20.20'; /** * The base path for the Laravel installation. From ab703aa6d5358c162df212d7924f17eaf26aaa73 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 23 Mar 2021 19:44:14 +0200 Subject: [PATCH 43/67] [6.x] update changelog --- CHANGELOG-6.x.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 226fdd550d8a..cc073b4d93fb 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,15 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.19...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.20...6.x) + + +## [v6.20.20 (2021-03-23)](https://github.com/laravel/framework/compare/v6.20.19...v6.20.20) + +### Added +- Added WSREP communication link failure for lost connection detection ([#36668](https://github.com/laravel/framework/pull/36668)) + +### Fixed +- Fixes the issue using cache:clear with PhpRedis and a clustered Redis instance. ([#36665](https://github.com/laravel/framework/pull/36665)) ## [v6.20.19 (2021-03-16)](https://github.com/laravel/framework/compare/v6.20.18...v6.20.19) From 5be0afe0f5a712a8256c0f6cfad6842c2bd779a1 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 25 Mar 2021 19:01:53 +0100 Subject: [PATCH 44/67] [6.x] DynamoDB in CI suite (#36749) * Set up DynamoDB testing * env variable * Random AWS keys * AWS endpoint * try different port * Try localhost * Dynamically create table * Add provider * uppercase * KeySchema * Update table * Apply fixes from StyleCI (#36746) * throughput * exception message * Switch env statement * Remove directory --- .github/workflows/tests.yml | 9 +++ src/Illuminate/Cache/CacheManager.php | 16 +---- src/Illuminate/Cache/CacheServiceProvider.php | 17 ++++- tests/Integration/Cache/DynamoDbStoreTest.php | 68 ++++++++++++++++--- 4 files changed, 85 insertions(+), 25 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a81af4975b9..ffe3c5a7b2e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,11 +63,20 @@ jobs: max_attempts: 5 command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + - name: Setup DynamoDB Local + uses: rrainn/dynamodb-action@v2.0.0 + with: + port: 8888 + - name: Execute tests run: vendor/bin/phpunit --verbose env: DB_PORT: ${{ job.services.mysql.ports[3306] }} DB_USERNAME: root + DYNAMODB_CACHE_TABLE: laravel_dynamodb_test + DYNAMODB_ENDPOINT: "http://localhost:8888" + AWS_ACCESS_KEY_ID: random_key + AWS_SECRET_ACCESS_KEY: random_secret windows_tests: runs-on: windows-latest diff --git a/src/Illuminate/Cache/CacheManager.php b/src/Illuminate/Cache/CacheManager.php index 33d1027bce1a..42bfc7271d59 100755 --- a/src/Illuminate/Cache/CacheManager.php +++ b/src/Illuminate/Cache/CacheManager.php @@ -2,12 +2,10 @@ namespace Illuminate\Cache; -use Aws\DynamoDb\DynamoDbClient; use Closure; use Illuminate\Contracts\Cache\Factory as FactoryContract; use Illuminate\Contracts\Cache\Store; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; -use Illuminate\Support\Arr; use InvalidArgumentException; /** @@ -226,21 +224,9 @@ protected function createDatabaseDriver(array $config) */ protected function createDynamodbDriver(array $config) { - $dynamoConfig = [ - 'region' => $config['region'], - 'version' => 'latest', - 'endpoint' => $config['endpoint'] ?? null, - ]; - - if ($config['key'] && $config['secret']) { - $dynamoConfig['credentials'] = Arr::only( - $config, ['key', 'secret', 'token'] - ); - } - return $this->repository( new DynamoDbStore( - new DynamoDbClient($dynamoConfig), + $this->app['cache.dynamodb.client'], $config['table'], $config['attributes']['key'] ?? 'key', $config['attributes']['value'] ?? 'value', diff --git a/src/Illuminate/Cache/CacheServiceProvider.php b/src/Illuminate/Cache/CacheServiceProvider.php index 46fa0ae2615c..90d1d019f4be 100755 --- a/src/Illuminate/Cache/CacheServiceProvider.php +++ b/src/Illuminate/Cache/CacheServiceProvider.php @@ -2,7 +2,9 @@ namespace Illuminate\Cache; +use Aws\DynamoDb\DynamoDbClient; use Illuminate\Contracts\Support\DeferrableProvider; +use Illuminate\Support\Arr; use Illuminate\Support\ServiceProvider; use Symfony\Component\Cache\Adapter\Psr16Adapter; @@ -30,6 +32,19 @@ public function register() $this->app->singleton('memcached.connector', function () { return new MemcachedConnector; }); + + $this->app->singleton('cache.dynamodb.client', function ($app) { + $config = $app['config']->get('cache.stores.dynamodb'); + + return new DynamoDbClient([ + 'region' => $config['region'], + 'version' => 'latest', + 'endpoint' => $config['endpoint'] ?? null, + 'credentials' => Arr::only( + $config, ['key', 'secret', 'token'] + ), + ]); + }); } /** @@ -40,7 +55,7 @@ public function register() public function provides() { return [ - 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', + 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', 'cache.dynamodb.client', ]; } } diff --git a/tests/Integration/Cache/DynamoDbStoreTest.php b/tests/Integration/Cache/DynamoDbStoreTest.php index 74897fbde8cb..f7aeae6a3deb 100644 --- a/tests/Integration/Cache/DynamoDbStoreTest.php +++ b/tests/Integration/Cache/DynamoDbStoreTest.php @@ -2,6 +2,8 @@ namespace Illuminate\Tests\Integration\Cache; +use Aws\DynamoDb\DynamoDbClient; +use Aws\Exception\AwsException; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Orchestra\Testbench\TestCase; @@ -13,11 +15,11 @@ class DynamoDbStoreTest extends TestCase { protected function setUp(): void { - parent::setUp(); - if (! env('DYNAMODB_CACHE_TABLE')) { $this->markTestSkipped('DynamoDB not configured.'); } + + parent::setUp(); } public function testItemsCanBeStoredAndRetrieved() @@ -74,15 +76,63 @@ public function testLocksCanBeAcquired() */ protected function getEnvironmentSetUp($app) { + if (! env('DYNAMODB_CACHE_TABLE')) { + $this->markTestSkipped('DynamoDB not configured.'); + } + $app['config']->set('cache.default', 'dynamodb'); - $app['config']->set('cache.stores.dynamodb', [ - 'driver' => 'dynamodb', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => 'us-east-1', - 'table' => env('DYNAMODB_CACHE_TABLE', 'laravel_test'), - 'endpoint' => env('DYNAMODB_ENDPOINT'), + $config = $app['config']->get('cache.stores.dynamodb'); + + /** @var \Aws\DynamoDb\DynamoDbClient $client */ + $client = $app['cache.dynamodb.client']; + + if ($this->dynamoTableExists($client, $config['table'])) { + return; + } + + $client->createTable([ + 'TableName' => $config['table'], + 'KeySchema' => [ + [ + 'AttributeName' => $config['attributes']['key'] ?? 'key', + 'KeyType' => 'HASH', + ], + ], + 'AttributeDefinitions' => [ + [ + 'AttributeName' => $config['attributes']['key'] ?? 'key', + 'AttributeType' => 'S', + ], + ], + 'ProvisionedThroughput' => [ + 'ReadCapacityUnits' => 1, + 'WriteCapacityUnits' => 1, + ], ]); } + + /** + * Determine if the given DynamoDB table exists. + * + * @param \Aws\DynamoDb\DynamoDbClient $client + * @param string $table + * @return bool + */ + public function dynamoTableExists(DynamoDbClient $client, $table) + { + try { + $client->describeTable([ + 'TableName' => $table, + ]); + + return true; + } catch (AwsException $e) { + if (Str::contains($e->getAwsErrorMessage(), ['resource not found', 'Cannot do operations on a non-existent table'])) { + return false; + } + + throw $e; + } + } } From efba08c637bd39ecbb1a5279b3f43965e1807f5e Mon Sep 17 00:00:00 2001 From: Jitendra Date: Fri, 26 Mar 2021 20:18:48 +0530 Subject: [PATCH 45/67] Removed filter on username for redis configuration parameter. (#36762) Co-authored-by: dschobert --- src/Illuminate/Redis/RedisManager.php | 2 +- tests/Redis/RedisConnectorTest.php | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Redis/RedisManager.php b/src/Illuminate/Redis/RedisManager.php index b5d98203c180..8a6c88d1c2ba 100644 --- a/src/Illuminate/Redis/RedisManager.php +++ b/src/Illuminate/Redis/RedisManager.php @@ -192,7 +192,7 @@ protected function parseConnectionConfiguration($config) } return array_filter($parsed, function ($key) { - return ! in_array($key, ['driver', 'username'], true); + return ! in_array($key, ['driver'], true); }, ARRAY_FILTER_USE_KEY); } diff --git a/tests/Redis/RedisConnectorTest.php b/tests/Redis/RedisConnectorTest.php index 599fa2f2aad3..0203ed9d9b82 100644 --- a/tests/Redis/RedisConnectorTest.php +++ b/tests/Redis/RedisConnectorTest.php @@ -160,4 +160,27 @@ public function testScheme() $this->assertEquals("tcp://{$host}", $phpRedisClient->getHost()); $this->assertEquals($port, $phpRedisClient->getPort()); } + + public function testPredisConfigurationWithUsername() + { + $host = env('REDIS_HOST', '127.0.0.1'); + $port = env('REDIS_PORT', 6379); + $username = 'testuser'; + $password = 'testpw'; + + $predis = new RedisManager(new Application, 'predis', [ + 'default' => [ + 'host' => $host, + 'port' => $port, + 'username' => $username, + 'password' => $password, + 'database' => 5, + 'timeout' => 0.5, + ], + ]); + $predisClient = $predis->connection()->client(); + $parameters = $predisClient->getConnection()->getParameters(); + $this->assertEquals($username, $parameters->username); + $this->assertEquals($password, $parameters->password); + } } From 006ba38124df6a8a651546a0301d604665b394b7 Mon Sep 17 00:00:00 2001 From: vdlp-mw <47185594+vdlp-mw@users.noreply.github.com> Date: Fri, 26 Mar 2021 16:54:12 +0100 Subject: [PATCH 46/67] Use qualified column names in pivot query (#36720) Co-authored-by: Menzo Wijmenga --- .../Eloquent/Relations/Concerns/InteractsWithPivotTable.php | 4 ++-- tests/Database/DatabaseEloquentMorphToManyTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php index c6812b75a150..b0abf2848590 100644 --- a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php +++ b/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php @@ -429,7 +429,7 @@ public function detach($ids = null, $touch = true) return 0; } - $query->whereIn($this->relatedPivotKey, (array) $ids); + $query->whereIn($this->getQualifiedRelatedPivotKeyName(), (array) $ids); } // Once we have all of the conditions set on the statement, we are ready @@ -544,7 +544,7 @@ public function newPivotQuery() $query->whereIn(...$arguments); } - return $query->where($this->foreignPivotKey, $this->parent->{$this->parentKey}); + return $query->where($this->getQualifiedForeignPivotKeyName(), $this->parent->{$this->parentKey}); } /** diff --git a/tests/Database/DatabaseEloquentMorphToManyTest.php b/tests/Database/DatabaseEloquentMorphToManyTest.php index 0b4a7f511074..dac94e258c39 100644 --- a/tests/Database/DatabaseEloquentMorphToManyTest.php +++ b/tests/Database/DatabaseEloquentMorphToManyTest.php @@ -47,9 +47,9 @@ public function testDetachRemovesPivotTableRecord() $relation = $this->getMockBuilder(MorphToMany::class)->setMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock(); $query = m::mock(stdClass::class); $query->shouldReceive('from')->once()->with('taggables')->andReturn($query); - $query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query); + $query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query); $query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query); - $query->shouldReceive('whereIn')->once()->with('tag_id', [1, 2, 3]); + $query->shouldReceive('whereIn')->once()->with('taggables.tag_id', [1, 2, 3]); $query->shouldReceive('delete')->once()->andReturn(true); $relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock(stdClass::class)); $mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query); @@ -63,7 +63,7 @@ public function testDetachMethodClearsAllPivotRecordsWhenNoIDsAreGiven() $relation = $this->getMockBuilder(MorphToMany::class)->setMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock(); $query = m::mock(stdClass::class); $query->shouldReceive('from')->once()->with('taggables')->andReturn($query); - $query->shouldReceive('where')->once()->with('taggable_id', 1)->andReturn($query); + $query->shouldReceive('where')->once()->with('taggables.taggable_id', 1)->andReturn($query); $query->shouldReceive('where')->once()->with('taggable_type', get_class($relation->getParent()))->andReturn($query); $query->shouldReceive('whereIn')->never(); $query->shouldReceive('delete')->once()->andReturn(true); From 35e339bffda785ae0cee11c66a17644a9fa096d1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 30 Mar 2021 09:08:57 -0500 Subject: [PATCH 47/67] patch --- 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 4e4d6c1840d3..a4f66d94d1f6 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.20'; + const VERSION = '6.20.21'; /** * The base path for the Laravel installation. From 8e1f620febb4d500f79f71be5b99697f2ae79a05 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 30 Mar 2021 23:33:10 +0200 Subject: [PATCH 48/67] Fix setting DynamoDB credentials (#36822) --- src/Illuminate/Cache/CacheServiceProvider.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Cache/CacheServiceProvider.php b/src/Illuminate/Cache/CacheServiceProvider.php index 90d1d019f4be..b8208eb4f549 100755 --- a/src/Illuminate/Cache/CacheServiceProvider.php +++ b/src/Illuminate/Cache/CacheServiceProvider.php @@ -36,14 +36,19 @@ public function register() $this->app->singleton('cache.dynamodb.client', function ($app) { $config = $app['config']->get('cache.stores.dynamodb'); - return new DynamoDbClient([ + $dynamoConfig = [ 'region' => $config['region'], 'version' => 'latest', 'endpoint' => $config['endpoint'] ?? null, - 'credentials' => Arr::only( + ]; + + if ($config['key'] && $config['secret']) { + $dynamoConfig['credentials'] = Arr::only( $config, ['key', 'secret', 'token'] - ), - ]); + ); + } + + return new DynamoDbClient($dynamoConfig); }); } From f4d2beff6f1793909e1db4f2204800183b4f1719 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 30 Mar 2021 16:33:47 -0500 Subject: [PATCH 49/67] 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 a4f66d94d1f6..34bbb83f924a 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.21'; + const VERSION = '6.20.22'; /** * The base path for the Laravel installation. From 071e1e03c3c455501d25d422ee9d7f3e6fcdb596 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Fri, 2 Apr 2021 21:48:47 +0300 Subject: [PATCH 50/67] [6.x] update changelog --- CHANGELOG-6.x.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index cc073b4d93fb..3e7eb5399740 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,16 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.20...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.21...6.x) + + +## [v6.20.21 (2021-03-30)](https://github.com/laravel/framework/compare/v6.20.20...v6.20.21) + +### Added +- Added support of DynamoDB in CI suite ([#36749](https://github.com/laravel/framework/pull/36749)) +- Support username parameter for predis ([#36762](https://github.com/laravel/framework/pull/36762)) + +### Changed +- Use qualified column names in pivot query ([#36720](https://github.com/laravel/framework/pull/36720)) ## [v6.20.20 (2021-03-23)](https://github.com/laravel/framework/compare/v6.20.19...v6.20.20) From f1e98e6da0f58b2feb7d8f376370e8889721e2cf Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Fri, 2 Apr 2021 21:51:10 +0300 Subject: [PATCH 51/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 3e7eb5399740..c88ba87c7212 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.21...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.22...6.x) + + +## [v6.20.22 (2021-03-31)](https://github.com/laravel/framework/compare/v6.20.21...v6.20.22) + +### Fixed +- Fixed setting DynamoDB credentials ([#36822](https://github.com/laravel/framework/pull/36822)) ## [v6.20.21 (2021-03-30)](https://github.com/laravel/framework/compare/v6.20.20...v6.20.21) From 42102589bc7f7b8533ee1b815ef0cc18017d4e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rihards=20=C5=A0=C4=8Deredins?= Date: Thu, 8 Apr 2021 15:38:18 +0300 Subject: [PATCH 52/67] Add more messages for detecting lost connection (happens during managed PostgreSQL upgrade on DigitalOcean) (#36911) --- src/Illuminate/Database/DetectsLostConnections.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Illuminate/Database/DetectsLostConnections.php b/src/Illuminate/Database/DetectsLostConnections.php index 191eefedc891..93be53b2fdc9 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -52,6 +52,8 @@ protected function causedByLostConnection(Throwable $e) 'Temporary failure in name resolution', 'SSL: Broken pipe', 'SQLSTATE[08S01]: Communication link failure', + 'SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host', + 'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: No route to host', ]); } } From e1f36fa3819c0d4b155dadcf19926d73045b9784 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 13 Apr 2021 15:06:47 +0200 Subject: [PATCH 53/67] [6.x] Fix required_if boolean validation (#36967) * Fix required_if boolean validation * Update ValidatesAttributes.php Co-authored-by: Taylor Otwell --- .../Validation/Concerns/ValidatesAttributes.php | 13 ++++++++++++- tests/Validation/ValidationValidatorTest.php | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 13fe1a648108..68b38aa8491c 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1475,13 +1475,24 @@ protected function prepareValuesAndOther($parameters) $values = array_slice($parameters, 1); - if (is_bool($other)) { + if ($this->shouldConvertToBoolean($parameters[0]) || is_bool($other)) { $values = $this->convertValuesToBoolean($values); } return [$values, $other]; } + /** + * Check if parameter should be converted to boolean. + * + * @param string $parameter + * @return bool + */ + protected function shouldConvertToBoolean($parameter) + { + return in_array('boolean', Arr::get($this->rules, $parameter, [])); + } + /** * Convert the given values to boolean if they are string "true" / "false". * diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 4ac71213c984..2938f18e92b0 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1090,6 +1090,17 @@ public function testRequiredIf() $v = new Validator($trans, ['first' => 'dayle', 'last' => ''], ['last' => 'RequiredIf:first,taylor,dayle']); $this->assertFalse($v->passes()); $this->assertSame('The last field is required when first is dayle.', $v->messages()->first('last')); + + $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); + $v = new Validator($trans, ['foo' => 0], [ + 'foo' => 'required|boolean', + 'bar' => 'required_if:foo,true', + 'baz' => 'required_if:foo,false', + ]); + $this->assertTrue($v->fails()); + $this->assertCount(1, $v->messages()); + $this->assertSame('The baz field is required when foo is 0.', $v->messages()->first('baz')); } public function testRequiredUnless() From 63655bf44ad7c3b2483c4a3c112831326f92e68c Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 13 Apr 2021 15:39:47 +0200 Subject: [PATCH 54/67] Revert "[6.x] Fix required_if boolean validation (#36967)" This reverts commit e1f36fa3819c0d4b155dadcf19926d73045b9784. --- .../Validation/Concerns/ValidatesAttributes.php | 13 +------------ tests/Validation/ValidationValidatorTest.php | 11 ----------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 68b38aa8491c..13fe1a648108 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1475,24 +1475,13 @@ protected function prepareValuesAndOther($parameters) $values = array_slice($parameters, 1); - if ($this->shouldConvertToBoolean($parameters[0]) || is_bool($other)) { + if (is_bool($other)) { $values = $this->convertValuesToBoolean($values); } return [$values, $other]; } - /** - * Check if parameter should be converted to boolean. - * - * @param string $parameter - * @return bool - */ - protected function shouldConvertToBoolean($parameter) - { - return in_array('boolean', Arr::get($this->rules, $parameter, [])); - } - /** * Convert the given values to boolean if they are string "true" / "false". * diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 2938f18e92b0..4ac71213c984 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1090,17 +1090,6 @@ public function testRequiredIf() $v = new Validator($trans, ['first' => 'dayle', 'last' => ''], ['last' => 'RequiredIf:first,taylor,dayle']); $this->assertFalse($v->passes()); $this->assertSame('The last field is required when first is dayle.', $v->messages()->first('last')); - - $trans = $this->getIlluminateArrayTranslator(); - $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); - $v = new Validator($trans, ['foo' => 0], [ - 'foo' => 'required|boolean', - 'bar' => 'required_if:foo,true', - 'baz' => 'required_if:foo,false', - ]); - $this->assertTrue($v->fails()); - $this->assertCount(1, $v->messages()); - $this->assertSame('The baz field is required when foo is 0.', $v->messages()->first('baz')); } public function testRequiredUnless() From d94c07d72c14f07e7d2027458e7f0a76f9ceb0d9 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 13 Apr 2021 08:49:28 -0500 Subject: [PATCH 55/67] patch --- 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 34bbb83f924a..9e37bd61811d 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.22'; + const VERSION = '6.20.23'; /** * The base path for the Laravel installation. From 15b6358cc285365970b6e9bd9d44e7f9b739db6d Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 14 Apr 2021 13:58:24 +0200 Subject: [PATCH 56/67] Revert "Revert "[6.x] Fix required_if boolean validation"" (#36969) --- .../Validation/Concerns/ValidatesAttributes.php | 13 ++++++++++++- tests/Validation/ValidationValidatorTest.php | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 13fe1a648108..68b38aa8491c 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1475,13 +1475,24 @@ protected function prepareValuesAndOther($parameters) $values = array_slice($parameters, 1); - if (is_bool($other)) { + if ($this->shouldConvertToBoolean($parameters[0]) || is_bool($other)) { $values = $this->convertValuesToBoolean($values); } return [$values, $other]; } + /** + * Check if parameter should be converted to boolean. + * + * @param string $parameter + * @return bool + */ + protected function shouldConvertToBoolean($parameter) + { + return in_array('boolean', Arr::get($this->rules, $parameter, [])); + } + /** * Convert the given values to boolean if they are string "true" / "false". * diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 4ac71213c984..2938f18e92b0 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1090,6 +1090,17 @@ public function testRequiredIf() $v = new Validator($trans, ['first' => 'dayle', 'last' => ''], ['last' => 'RequiredIf:first,taylor,dayle']); $this->assertFalse($v->passes()); $this->assertSame('The last field is required when first is dayle.', $v->messages()->first('last')); + + $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); + $v = new Validator($trans, ['foo' => 0], [ + 'foo' => 'required|boolean', + 'bar' => 'required_if:foo,true', + 'baz' => 'required_if:foo,false', + ]); + $this->assertTrue($v->fails()); + $this->assertCount(1, $v->messages()); + $this->assertSame('The baz field is required when foo is 0.', $v->messages()->first('baz')); } public function testRequiredUnless() From 5531a599e15ff3c3acc0affa18e3824242b52ba3 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Thu, 15 Apr 2021 23:51:22 +0300 Subject: [PATCH 57/67] [6.x] update changelog --- CHANGELOG-6.x.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index c88ba87c7212..614783adc58f 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,11 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.22...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.23...6.x) + + +## [v6.20.23 (2021-04-13)](https://github.com/laravel/framework/compare/v6.20.22...v6.20.23) + +### Added strings to the `DetectsLostConnections.php` ([4210258](https://github.com/laravel/framework/commit/42102589bc7f7b8533ee1b815ef0cc18017d4e45)) ## [v6.20.22 (2021-03-31)](https://github.com/laravel/framework/compare/v6.20.21...v6.20.22) From 402ca919344c25c67b487a12e4a8b6edb0cdfc57 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Thu, 15 Apr 2021 23:51:45 +0300 Subject: [PATCH 58/67] [6.x] update changelog --- CHANGELOG-6.x.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 614783adc58f..0a43e37ec935 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -5,7 +5,8 @@ ## [v6.20.23 (2021-04-13)](https://github.com/laravel/framework/compare/v6.20.22...v6.20.23) -### Added strings to the `DetectsLostConnections.php` ([4210258](https://github.com/laravel/framework/commit/42102589bc7f7b8533ee1b815ef0cc18017d4e45)) +### Added +- Added strings to the `DetectsLostConnections.php` ([4210258](https://github.com/laravel/framework/commit/42102589bc7f7b8533ee1b815ef0cc18017d4e45)) ## [v6.20.22 (2021-03-31)](https://github.com/laravel/framework/compare/v6.20.21...v6.20.22) From addc44fce390c783b2dee0d617300dce97e895f4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 20 Apr 2021 08:46:19 -0500 Subject: [PATCH 59/67] patch --- 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 9e37bd61811d..477a7f05c0f2 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.23'; + const VERSION = '6.20.24'; /** * The base path for the Laravel installation. From 8c61f6c6d1dfb7fbd8a56a6090b405571e159715 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 21 Apr 2021 20:51:22 +0300 Subject: [PATCH 60/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 0a43e37ec935..aa8665af117c 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.23...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.24...6.x) + + +## [v6.20.24 (2021-04-20)](https://github.com/laravel/framework/compare/v6.20.23...v6.20.24) + +### Fixed +- Fixed required_if boolean validation ([#36969](https://github.com/laravel/framework/pull/36969)) ## [v6.20.23 (2021-04-13)](https://github.com/laravel/framework/compare/v6.20.22...v6.20.23) From 5b604e19f2b8bd95b72cd8e6a82e7164d9b05537 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 27 Apr 2021 15:40:27 +0200 Subject: [PATCH 61/67] [6.x] Fix nullable values for required_if (#37128) * Fix nullable values for required_if * Reword null value --- .../Validation/Concerns/FormatsMessages.php | 4 + .../Concerns/ValidatesAttributes.php | 82 +++++++++++++++---- tests/Validation/ValidationValidatorTest.php | 33 +++++++- 3 files changed, 101 insertions(+), 18 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/FormatsMessages.php b/src/Illuminate/Validation/Concerns/FormatsMessages.php index 9d011892aaf7..737d4173d174 100644 --- a/src/Illuminate/Validation/Concerns/FormatsMessages.php +++ b/src/Illuminate/Validation/Concerns/FormatsMessages.php @@ -336,6 +336,10 @@ public function getDisplayableValue($attribute, $value) return $value ? 'true' : 'false'; } + if (is_null($value)) { + return 'empty'; + } + return $value; } diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 68b38aa8491c..034e7db049a6 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1420,9 +1420,13 @@ public function validateRequiredIf($attribute, $value, $parameters) { $this->requireParameterCount(2, $parameters, 'required_if'); + if (! Arr::has($this->data, $parameters[0])) { + return true; + } + [$values, $other] = $this->prepareValuesAndOther($parameters); - if (in_array($other, $values, is_bool($other))) { + if (in_array($other, $values, is_bool($other) || is_null($other))) { return $this->validateRequired($attribute, $value); } @@ -1441,9 +1445,13 @@ public function validateExcludeIf($attribute, $value, $parameters) { $this->requireParameterCount(2, $parameters, 'exclude_if'); + if (! Arr::has($this->data, $parameters[0])) { + return true; + } + [$values, $other] = $this->prepareValuesAndOther($parameters); - return ! in_array($other, $values, is_bool($other)); + return ! in_array($other, $values, is_bool($other) || is_null($other)); } /** @@ -1458,9 +1466,38 @@ public function validateExcludeUnless($attribute, $value, $parameters) { $this->requireParameterCount(2, $parameters, 'exclude_unless'); + if (! Arr::has($this->data, $parameters[0])) { + return true; + } + [$values, $other] = $this->prepareValuesAndOther($parameters); - return in_array($other, $values, is_bool($other)); + return in_array($other, $values, is_bool($other) || is_null($other)); + } + + /** + * Validate that an attribute exists when another attribute does not have a given value. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + public function validateRequiredUnless($attribute, $value, $parameters) + { + $this->requireParameterCount(2, $parameters, 'required_unless'); + + if (! Arr::has($this->data, $parameters[0])) { + return true; + } + + [$values, $other] = $this->prepareValuesAndOther($parameters); + + if (! in_array($other, $values, is_bool($other) || is_null($other))) { + return $this->validateRequired($attribute, $value); + } + + return true; } /** @@ -1479,6 +1516,10 @@ protected function prepareValuesAndOther($parameters) $values = $this->convertValuesToBoolean($values); } + if ($this->shouldConvertToNull($parameters[0]) || is_null($other)) { + $values = $this->convertValuesToNull($values); + } + return [$values, $other]; } @@ -1493,6 +1534,17 @@ protected function shouldConvertToBoolean($parameter) return in_array('boolean', Arr::get($this->rules, $parameter, [])); } + /** + * Check if parameter should be converted to null. + * + * @param string $parameter + * @return bool + */ + protected function shouldConvertToNull($parameter) + { + return in_array('nullable', Arr::get($this->rules, $parameter, [])); + } + /** * Convert the given values to boolean if they are string "true" / "false". * @@ -1513,24 +1565,20 @@ protected function convertValuesToBoolean($values) } /** - * Validate that an attribute exists when another attribute does not have a given value. + * Convert the given values to null if they are string "null". * - * @param string $attribute - * @param mixed $value - * @param mixed $parameters - * @return bool + * @param array $values + * @return array */ - public function validateRequiredUnless($attribute, $value, $parameters) + protected function convertValuesToNull($values) { - $this->requireParameterCount(2, $parameters, 'required_unless'); - - [$values, $other] = $this->prepareValuesAndOther($parameters); - - if (! in_array($other, $values, is_bool($other))) { - return $this->validateRequired($attribute, $value); - } + return array_map(function ($value) { + if ($value === 'null') { + return null; + } - return true; + return $value; + }, $values); } /** diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 2938f18e92b0..b90b7cfdb373 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1094,13 +1094,44 @@ public function testRequiredIf() $trans = $this->getIlluminateArrayTranslator(); $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); $v = new Validator($trans, ['foo' => 0], [ - 'foo' => 'required|boolean', + 'foo' => 'nullable|required|boolean', 'bar' => 'required_if:foo,true', 'baz' => 'required_if:foo,false', ]); $this->assertTrue($v->fails()); $this->assertCount(1, $v->messages()); $this->assertSame('The baz field is required when foo is 0.', $v->messages()->first('baz')); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, [], [ + 'foo' => 'nullable|boolean', + 'baz' => 'nullable|required_if:foo,false', + ]); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, ['foo' => null], [ + 'foo' => 'nullable|boolean', + 'baz' => 'nullable|required_if:foo,false', + ]); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $v = new Validator($trans, [], [ + 'foo' => 'nullable|boolean', + 'baz' => 'nullable|required_if:foo,null', + ]); + $this->assertTrue($v->passes()); + + $trans = $this->getIlluminateArrayTranslator(); + $trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en'); + $v = new Validator($trans, ['foo' => null], [ + 'foo' => 'nullable|boolean', + 'baz' => 'nullable|required_if:foo,null', + ]); + $this->assertTrue($v->fails()); + $this->assertCount(1, $v->messages()); + $this->assertSame('The baz field is required when foo is empty.', $v->messages()->first('baz')); } public function testRequiredUnless() From 86fd558b4e5d8d7d45cf457cd1a72d54334297a1 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 27 Apr 2021 16:01:46 +0200 Subject: [PATCH 62/67] Remove redundant check --- .../Concerns/ValidatesAttributes.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 034e7db049a6..2ddbff3f0365 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1516,7 +1516,7 @@ protected function prepareValuesAndOther($parameters) $values = $this->convertValuesToBoolean($values); } - if ($this->shouldConvertToNull($parameters[0]) || is_null($other)) { + if (is_null($other)) { $values = $this->convertValuesToNull($values); } @@ -1534,17 +1534,6 @@ protected function shouldConvertToBoolean($parameter) return in_array('boolean', Arr::get($this->rules, $parameter, [])); } - /** - * Check if parameter should be converted to null. - * - * @param string $parameter - * @return bool - */ - protected function shouldConvertToNull($parameter) - { - return in_array('nullable', Arr::get($this->rules, $parameter, [])); - } - /** * Convert the given values to boolean if they are string "true" / "false". * @@ -1573,11 +1562,7 @@ protected function convertValuesToBoolean($values) protected function convertValuesToNull($values) { return array_map(function ($value) { - if ($value === 'null') { - return null; - } - - return $value; + return Str::lower($value) === 'null' ? null : $value; }, $values); } From d6f8b14c09c324fa81e028231e89a2a8f4907b2f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 27 Apr 2021 09:22:09 -0500 Subject: [PATCH 63/67] patch --- 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 477a7f05c0f2..f22368b1f443 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.24'; + const VERSION = '6.20.25'; /** * The base path for the Laravel installation. From bf0b653ead2ae6f340410508a3c94c1366a48405 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Tue, 27 Apr 2021 22:53:39 +0300 Subject: [PATCH 64/67] [6.x] update changelog --- CHANGELOG-6.x.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index aa8665af117c..1190419cef6e 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,12 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.24...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.25...6.x) + + +## [v6.20.25 (2021-04-27)](https://github.com/laravel/framework/compare/v6.20.24...v6.20.25) + +### Fixed +- Fixed nullable values for required_if ([#37128](https://github.com/laravel/framework/pull/37128), [86fd558](https://github.com/laravel/framework/commit/86fd558b4e5d8d7d45cf457cd1a72d54334297a1)) ## [v6.20.24 (2021-04-20)](https://github.com/laravel/framework/compare/v6.20.23...v6.20.24) From 74a79b211712b8428dc0d3453da545867402a37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Aur=C3=A9lio=20Deleu?= Date: Tue, 27 Apr 2021 22:16:03 +0200 Subject: [PATCH 65/67] [6.x] Fix Cache store with a name other than 'dynamodb' (#37145) * Fix Cache store with a name other than 'dynamodb' * StyleCI --- src/Illuminate/Cache/CacheManager.php | 28 ++++++++++++++++++- src/Illuminate/Cache/CacheServiceProvider.php | 22 +-------------- src/Illuminate/Cache/DynamoDbStore.php | 10 +++++++ tests/Integration/Cache/DynamoDbStoreTest.php | 3 +- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/Illuminate/Cache/CacheManager.php b/src/Illuminate/Cache/CacheManager.php index 42bfc7271d59..1f514369d34e 100755 --- a/src/Illuminate/Cache/CacheManager.php +++ b/src/Illuminate/Cache/CacheManager.php @@ -2,10 +2,12 @@ namespace Illuminate\Cache; +use Aws\DynamoDb\DynamoDbClient; use Closure; use Illuminate\Contracts\Cache\Factory as FactoryContract; use Illuminate\Contracts\Cache\Store; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; +use Illuminate\Support\Arr; use InvalidArgumentException; /** @@ -224,9 +226,11 @@ protected function createDatabaseDriver(array $config) */ protected function createDynamodbDriver(array $config) { + $client = $this->newDynamodbClient($config); + return $this->repository( new DynamoDbStore( - $this->app['cache.dynamodb.client'], + $client, $config['table'], $config['attributes']['key'] ?? 'key', $config['attributes']['value'] ?? 'value', @@ -236,6 +240,28 @@ protected function createDynamodbDriver(array $config) ); } + /** + * Create new DynamoDb Client instance. + * + * @return DynamoDbClient + */ + protected function newDynamodbClient(array $config) + { + $dynamoConfig = [ + 'region' => $config['region'], + 'version' => 'latest', + 'endpoint' => $config['endpoint'] ?? null, + ]; + + if (isset($config['key']) && isset($config['secret'])) { + $dynamoConfig['credentials'] = Arr::only( + $config, ['key', 'secret', 'token'] + ); + } + + return new DynamoDbClient($dynamoConfig); + } + /** * Create a new cache repository with the given implementation. * diff --git a/src/Illuminate/Cache/CacheServiceProvider.php b/src/Illuminate/Cache/CacheServiceProvider.php index b8208eb4f549..46fa0ae2615c 100755 --- a/src/Illuminate/Cache/CacheServiceProvider.php +++ b/src/Illuminate/Cache/CacheServiceProvider.php @@ -2,9 +2,7 @@ namespace Illuminate\Cache; -use Aws\DynamoDb\DynamoDbClient; use Illuminate\Contracts\Support\DeferrableProvider; -use Illuminate\Support\Arr; use Illuminate\Support\ServiceProvider; use Symfony\Component\Cache\Adapter\Psr16Adapter; @@ -32,24 +30,6 @@ public function register() $this->app->singleton('memcached.connector', function () { return new MemcachedConnector; }); - - $this->app->singleton('cache.dynamodb.client', function ($app) { - $config = $app['config']->get('cache.stores.dynamodb'); - - $dynamoConfig = [ - 'region' => $config['region'], - 'version' => 'latest', - 'endpoint' => $config['endpoint'] ?? null, - ]; - - if ($config['key'] && $config['secret']) { - $dynamoConfig['credentials'] = Arr::only( - $config, ['key', 'secret', 'token'] - ); - } - - return new DynamoDbClient($dynamoConfig); - }); } /** @@ -60,7 +40,7 @@ public function register() public function provides() { return [ - 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', 'cache.dynamodb.client', + 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', ]; } } diff --git a/src/Illuminate/Cache/DynamoDbStore.php b/src/Illuminate/Cache/DynamoDbStore.php index 4e663db4108a..aa28a789fa36 100644 --- a/src/Illuminate/Cache/DynamoDbStore.php +++ b/src/Illuminate/Cache/DynamoDbStore.php @@ -525,4 +525,14 @@ public function setPrefix($prefix) { $this->prefix = ! empty($prefix) ? $prefix.':' : ''; } + + /** + * Get the DynamoDb Client instance. + * + * @return DynamoDbClient + */ + public function getClient() + { + return $this->dynamo; + } } diff --git a/tests/Integration/Cache/DynamoDbStoreTest.php b/tests/Integration/Cache/DynamoDbStoreTest.php index f7aeae6a3deb..318db8a1ce51 100644 --- a/tests/Integration/Cache/DynamoDbStoreTest.php +++ b/tests/Integration/Cache/DynamoDbStoreTest.php @@ -4,6 +4,7 @@ use Aws\DynamoDb\DynamoDbClient; use Aws\Exception\AwsException; +use Illuminate\Contracts\Cache\Repository; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Orchestra\Testbench\TestCase; @@ -85,7 +86,7 @@ protected function getEnvironmentSetUp($app) $config = $app['config']->get('cache.stores.dynamodb'); /** @var \Aws\DynamoDb\DynamoDbClient $client */ - $client = $app['cache.dynamodb.client']; + $client = $app->make(Repository::class)->getStore()->getClient(); if ($this->dynamoTableExists($client, $config['table'])) { return; From 09bf1457e9df53e172e6fd5929cbafb539677c7c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 28 Apr 2021 08:18:19 -0500 Subject: [PATCH 66/67] cast to int --- .../Database/Query/Grammars/SqlServerGrammar.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php index f0a0bfc5190b..88a7df3dc5e9 100755 --- a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php @@ -60,8 +60,8 @@ protected function compileColumns(Builder $query, $columns) // If there is a limit on the query, but not an offset, we will add the top // clause to the query, which serves as a "limit" type clause within the // SQL Server system similar to the limit keywords available in MySQL. - if ($query->limit > 0 && $query->offset <= 0) { - $select .= 'top '.$query->limit.' '; + if (is_numeric($query->limit) && $query->limit > 0 && $query->offset <= 0) { + $select .= 'top '.((int) $query->limit).' '; } return $select.$this->columnize($columns); @@ -221,10 +221,10 @@ protected function compileTableExpression($sql, $query) */ protected function compileRowConstraint($query) { - $start = $query->offset + 1; + $start = (int) $query->offset + 1; if ($query->limit > 0) { - $finish = $query->offset + $query->limit; + $finish = (int) $query->offset + (int) $query->limit; return "between {$start} and {$finish}"; } From 0117d797dc1ab64b1f88d4f6b966380ea7def091 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 28 Apr 2021 09:38:32 -0500 Subject: [PATCH 67/67] patch --- 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 f22368b1f443..14872999d6c4 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.25'; + const VERSION = '6.20.26'; /** * The base path for the Laravel installation.