Skip to content

Commit

Permalink
[5.5] Allow set cookie secure option when session secure default is t…
Browse files Browse the repository at this point in the history
…rue (#22812)

* tag v5.5.29 release notes

* Fix Collection dd() in browser preview window (#22803)

See #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
  • Loading branch information
joecohens authored and taylorotwell committed Jan 16, 2018
1 parent cf4a385 commit 530a835
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
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 @@ -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));
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 @@ -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()
Expand Down

0 comments on commit 530a835

Please sign in to comment.