diff --git a/CHANGELOG-6.x.md b/CHANGELOG-6.x.md index 8ec4a08e9afe..3ab00165cccc 100644 --- a/CHANGELOG-6.x.md +++ b/CHANGELOG-6.x.md @@ -1,6 +1,28 @@ # Release Notes for 6.x -## [Unreleased](https://github.com/laravel/framework/compare/v6.20.7...6.x) +## [Unreleased](https://github.com/laravel/framework/compare/v6.20.10...6.x) + + +## [v6.20.10 (2021-01-12)](https://github.com/laravel/framework/compare/v6.20.9...v6.20.10) + +### Added +- Added new line to `DetectsLostConnections` ([#35790](https://github.com/laravel/framework/pull/35790)) + +### Fixed +- Fixed error from missing null check on PHP 8 in `Illuminate\Validation\Concerns\ValidatesAttributes::validateJson()` ([#35797](https://github.com/laravel/framework/pull/35797)) + + +## [v6.20.9 (2021-01-05)](https://github.com/laravel/framework/compare/v6.20.8...v6.20.9) + +### Added +- [Updated Illuminate\Database\DetectsLostConnections with new strings](https://github.com/laravel/framework/compare/v6.20.8...v6.20.9) + + +## [v6.20.8 (2020-12-22)](https://github.com/laravel/framework/compare/v6.20.7...v6.20.8) + +### Fixed +- Fixed `Illuminate\Validation\Concerns\ValidatesAttributes::validateJson()` for PHP8 ([#35646](https://github.com/laravel/framework/pull/35646)) +- Catch DecryptException with invalid X-XSRF-TOKEN in `Illuminate\Foundation\Http\Middleware\VerifyCsrfToken` ([#35671](https://github.com/laravel/framework/pull/35671)) ## [v6.20.7 (2020-12-08)](https://github.com/laravel/framework/compare/v6.20.6...v6.20.7) diff --git a/CHANGELOG-7.x.md b/CHANGELOG-7.x.md index 7ef94e06eee9..2a0534809019 100644 --- a/CHANGELOG-7.x.md +++ b/CHANGELOG-7.x.md @@ -1,6 +1,15 @@ # Release Notes for 7.x -## [Unreleased](https://github.com/laravel/framework/compare/v7.30.0...7.x) +## [Unreleased](https://github.com/laravel/framework/compare/v7.30.1...7.x) + + +## [v7.30.1 (2020-12-22)](https://github.com/laravel/framework/compare/v7.30.0...v7.30.1) + +### Fixed +- Backport for fix issue with polymorphic morphMaps with literal 0 ([#35487](https://github.com/laravel/framework/pull/35487)) +- Fixed mime validation for jpeg files ([#35518](https://github.com/laravel/framework/pull/35518)) +- Fixed `Illuminate\Validation\Concerns\ValidatesAttributes::validateJson()` for PHP8 ([#35646](https://github.com/laravel/framework/pull/35646)) +- Catch DecryptException with invalid X-XSRF-TOKEN in `Illuminate\Foundation\Http\Middleware\VerifyCsrfToken` ([#35671](https://github.com/laravel/framework/pull/35671)) ## [v7.30.0 (2020-12-01)](https://github.com/laravel/framework/compare/v7.29.3...v7.30.0) diff --git a/src/Illuminate/Database/DetectsLostConnections.php b/src/Illuminate/Database/DetectsLostConnections.php index 36b46099983f..07630c590d5c 100644 --- a/src/Illuminate/Database/DetectsLostConnections.php +++ b/src/Illuminate/Database/DetectsLostConnections.php @@ -44,7 +44,11 @@ protected function causedByLostConnection(Throwable $e) 'running with the --read-only option so it cannot execute this statement', 'The connection is broken and recovery is not possible. The connection is marked by the client driver as unrecoverable. No attempt was made to restore the connection.', 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again', + 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known', 'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: EOF detected', + 'SQLSTATE[HY000] [2002] Connection timed out', + 'SSL: Connection timed out', + 'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', ]); } } diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index b9034c27e929..86283cb993f2 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -709,7 +709,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' ); if (! $value instanceof Expression) { - $this->addBinding($value, 'where'); + $this->addBinding(is_array($value) ? head($value) : $value, 'where'); } return $this; @@ -1078,7 +1078,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa $this->wheres[] = compact('type', 'column', 'values', 'boolean', 'not'); - $this->addBinding($this->cleanBindings($values), 'where'); + $this->addBinding(array_slice($this->cleanBindings($values), 0, 2), 'where'); return $this; } @@ -1201,6 +1201,8 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); + $value = is_array($value) ? head($value) : $value; + if ($value instanceof DateTimeInterface) { $value = $value->format('Y-m-d'); } @@ -1240,6 +1242,8 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); + $value = is_array($value) ? head($value) : $value; + if ($value instanceof DateTimeInterface) { $value = $value->format('H:i:s'); } @@ -1279,6 +1283,8 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); + $value = is_array($value) ? head($value) : $value; + if ($value instanceof DateTimeInterface) { $value = $value->format('d'); } @@ -1322,6 +1328,8 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); + $value = is_array($value) ? head($value) : $value; + if ($value instanceof DateTimeInterface) { $value = $value->format('m'); } @@ -1365,6 +1373,8 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') $value, $operator, func_num_args() === 2 ); + $value = is_array($value) ? head($value) : $value; + if ($value instanceof DateTimeInterface) { $value = $value->format('Y'); } @@ -1673,7 +1683,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); if (! $value instanceof Expression) { - $this->addBinding($value); + $this->addBinding((int) $value); } return $this; @@ -1822,7 +1832,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($value, 'having'); + $this->addBinding(is_array($value) ? head($value) : $value, 'having'); } return $this; diff --git a/src/Illuminate/Foundation/Application.php b/src/Illuminate/Foundation/Application.php index 89b2ede18866..34523e48057e 100755 --- a/src/Illuminate/Foundation/Application.php +++ b/src/Illuminate/Foundation/Application.php @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig * * @var string */ - const VERSION = '7.30.1'; + const VERSION = '7.30.2'; /** * The base path for the Laravel installation. diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index d3825e3b4f2d..eed211c81be5 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1174,7 +1174,7 @@ public function validateJson($attribute, $value) return false; } - if (! is_scalar($value) && ! method_exists($value, '__toString')) { + if (! is_scalar($value) && ! is_null($value) && ! method_exists($value, '__toString')) { return false; } diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index f6383e61e18d..b1a6d0f7d7a5 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -301,24 +301,24 @@ public function testBasicWheres() public function testWheresWithArrayValue() { $builder = $this->getBuilder(); - $builder->select('*')->from('users')->where('id', [12, 30]); + $builder->select('*')->from('users')->where('id', [12]); $this->assertSame('select * from "users" where "id" = ?', $builder->toSql()); - $this->assertEquals([0 => 12, 1 => 30], $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, 1 => 30], $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, 1 => 30], $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, 1 => 30], $builder->getBindings()); + $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, 1 => 30], $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, 1 => 30], $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, 1 => 30], $builder->getBindings()); } public function testMySqlWrappingProtectsQuotationMarks()