From 530a83542c648d6961567cdf2b4734fb868a933d Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Tue, 16 Jan 2018 07:38:36 -0600 Subject: [PATCH] [5.5] Allow set cookie secure option when session secure default is true (#22812) * tag v5.5.29 release notes * Fix Collection dd() in browser preview window (#22803) See https://github.com/laravel/framework/pull/22581 * [5.5] Allow only to accept collection of keys (#22804) * Modify only to accept collection of keys * Fix missing parentethes * Allow set cookie secure option when session secure default is true * Add tests case --- CHANGELOG-5.5.md | 6 +++++- src/Illuminate/Cookie/CookieJar.php | 20 ++++++++++---------- src/Illuminate/Support/Collection.php | 6 ++++++ tests/Cookie/CookieTest.php | 12 ++++++++++++ tests/Support/SupportCollectionTest.php | 2 ++ 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CHANGELOG-5.5.md b/CHANGELOG-5.5.md index b7251c3e1ea6..44981273d632 100644 --- a/CHANGELOG-5.5.md +++ b/CHANGELOG-5.5.md @@ -1,6 +1,6 @@ # Release Notes for 5.5.x -## [Unreleased] +## v5.5.29 (2018-01-15) ### Added - Added `Model::qualifyColumn()` method ([#22577](https://github.com/laravel/framework/pull/22577)) @@ -23,6 +23,7 @@ - Set `null` as default value for `optional()` helper ([#22699](https://github.com/laravel/framework/pull/22699)) - Make sure `getRememberToken()` returns a string ([#22724](https://github.com/laravel/framework/pull/22724)) - Updated Vue preset version ([#22732](https://github.com/laravel/framework/pull/22732)) +- Accept `Arrayable` items in `Collection::find()` ([#22787](https://github.com/laravel/framework/pull/22787)) ### Fixed - Close database connection when using `RefreshDatabase` trait ([#22569](https://github.com/laravel/framework/pull/22569)) @@ -30,6 +31,9 @@ - Fixed parameter usage in `RedirectController` ([#22657](https://github.com/laravel/framework/pull/22657)) - Added `__set_state()` method to `Support/Carbon` ([#22689](https://github.com/laravel/framework/pull/22689)) - Do not continue checking `APP_ENV` if environment file path being set successfully with `--env` option ([#22753](https://github.com/laravel/framework/pull/22753)) +- Fixed missing table prefix in `SQLiteGrammar::compileDropColumn()` ([#22745](https://github.com/laravel/framework/pull/22745), [c13322c](https://github.com/laravel/framework/commit/c13322c54a20de1417d7bf53e348a601c526bf54)) +- Fixed prefixing in `SQLiteGrammar::compileColumnListing()` ([#22781](https://github.com/laravel/framework/pull/22781)) + ## v5.5.28 (2017-12-26) diff --git a/src/Illuminate/Cookie/CookieJar.php b/src/Illuminate/Cookie/CookieJar.php index b4c65df5a12d..f792a6c7638e 100755 --- a/src/Illuminate/Cookie/CookieJar.php +++ b/src/Illuminate/Cookie/CookieJar.php @@ -54,13 +54,13 @@ class CookieJar implements JarContract * @param int $minutes * @param string $path * @param string $domain - * @param bool $secure + * @param bool|null $secure * @param bool $httpOnly * @param bool $raw * @param string|null $sameSite * @return \Symfony\Component\HttpFoundation\Cookie */ - public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true, $raw = false, $sameSite = null) + public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null) { list($path, $domain, $secure, $sameSite) = $this->getPathAndDomain($path, $domain, $secure, $sameSite); @@ -76,13 +76,13 @@ public function make($name, $value, $minutes = 0, $path = null, $domain = null, * @param string $value * @param string $path * @param string $domain - * @param bool $secure + * @param bool|null $secure * @param bool $httpOnly * @param bool $raw * @param string|null $sameSite * @return \Symfony\Component\HttpFoundation\Cookie */ - public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true, $raw = false, $sameSite = null) + public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null) { return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly, $raw, $sameSite); } @@ -154,15 +154,15 @@ public function unqueue($name) /** * Get the path and domain, or the default values. * - * @param string $path - * @param string $domain - * @param bool $secure - * @param string $sameSite + * @param string $path + * @param string $domain + * @param bool|null $secure + * @param string $sameSite * @return array */ - protected function getPathAndDomain($path, $domain, $secure = false, $sameSite = null) + protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null) { - return [$path ?: $this->path, $domain ?: $this->domain, $secure ?: $this->secure, $sameSite ?: $this->sameSite]; + return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite]; } /** diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 757f3593c55d..888c81a8137b 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -271,6 +271,8 @@ public function crossJoin(...$lists) */ public function dd(...$args) { + http_response_code(500); + call_user_func_array([$this, 'dump'], $args); die(1); @@ -1070,6 +1072,10 @@ public function only($keys) return new static($this->items); } + if ($keys instanceof self) { + $keys = $keys->all(); + } + $keys = is_array($keys) ? $keys : func_get_args(); return new static(Arr::only($this->items, $keys)); diff --git a/tests/Cookie/CookieTest.php b/tests/Cookie/CookieTest.php index 05dd787b8423..e2cde5639872 100755 --- a/tests/Cookie/CookieTest.php +++ b/tests/Cookie/CookieTest.php @@ -51,6 +51,18 @@ public function testCookiesAreCreatedWithProperOptionsUsingDefaultPathAndDomain( $this->assertEquals('lax', $c->getSameSite()); } + public function testCookiesCanSetSecureOptionUsingDefaultPathAndDomain() + { + $cookie = $this->getCreator(); + $cookie->setDefaultPathAndDomain('/path', '/domain', true, 'lax'); + $c = $cookie->make('color', 'blue', 10, null, null, false); + $this->assertEquals('blue', $c->getValue()); + $this->assertFalse($c->isSecure()); + $this->assertEquals('/domain', $c->getDomain()); + $this->assertEquals('/path', $c->getPath()); + $this->assertEquals('lax', $c->getSameSite()); + } + public function testQueuedCookies() { $cookie = $this->getCreator(); diff --git a/tests/Support/SupportCollectionTest.php b/tests/Support/SupportCollectionTest.php index 1327a34aea42..5b054395b362 100755 --- a/tests/Support/SupportCollectionTest.php +++ b/tests/Support/SupportCollectionTest.php @@ -1981,9 +1981,11 @@ public function testOnly() $this->assertEquals($data->all(), $data->only(null)->all()); $this->assertEquals(['first' => 'Taylor'], $data->only(['first', 'missing'])->all()); $this->assertEquals(['first' => 'Taylor'], $data->only('first', 'missing')->all()); + $this->assertEquals(['first' => 'Taylor'], $data->only(collect(['first', 'missing']))->all()); $this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only(['first', 'email'])->all()); $this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only('first', 'email')->all()); + $this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only(collect(['first', 'email']))->all()); } public function testGettingAvgItemsFromCollection()