Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Allow set cookie secure option when session secure default is true #22812

Merged
merged 5 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG-5.5.md
Original file line number Diff line number Diff line change
@@ -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))
Expand All @@ -23,13 +23,17 @@
- 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))
- Send status code `500` when using `dd()` ([#22581](https://github.com/laravel/framework/pull/22581))
- 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)

Expand Down
20 changes: 10 additions & 10 deletions src/Illuminate/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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];
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1060,6 +1062,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));
Expand Down
12 changes: 12 additions & 0 deletions tests/Cookie/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1970,9 +1970,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()
Expand Down