Skip to content

Commit 20ecf23

Browse files
committed
Merge remote-tracking branch 'origin/5.5' into 5.5
2 parents c792068 + cdc3f42 commit 20ecf23

File tree

8 files changed

+142
-12
lines changed

8 files changed

+142
-12
lines changed

CHANGELOG-5.5.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Release Notes for 5.5.x
22

3+
## v5.5.7 (2017-09-19)
4+
5+
### Fixed
6+
- Fix `CacheClearCommand` binding ([#21256](https://github.com/laravel/framework/pull/21256))
7+
8+
9+
## v5.5.6 (2017-09-19)
10+
11+
### Changed
12+
- Clear real-time facades when running `cache:clear` ([#21250](https://github.com/laravel/framework/pull/21250), [1856601](https://github.com/laravel/framework/commit/185660178ad213140411ca27550cdaf44c650002))
13+
14+
### Fixed
15+
- Reverted stable sort support in `Collection::sortBy()` ([#21255](https://github.com/laravel/framework/pull/21255))
16+
17+
318
## v5.5.5 (2017-09-19)
419

520
### Added

src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ public function updateExistingPivot($id, array $attributes, $touch = true)
188188
$attributes = $this->addTimestampsToAttachment($attributes, true);
189189
}
190190

191-
$updated = $this->newPivotStatementForId($id)->update($attributes);
191+
$updated = $this->newPivotStatementForId($id)->update(
192+
$this->castAttributes($attributes)
193+
);
192194

193195
if ($touch) {
194196
$this->touchIfTouching();
@@ -236,10 +238,6 @@ protected function formatAttachRecords($ids, array $attributes)
236238
// To create the attachment records, we will simply spin through the IDs given
237239
// and create a new record to insert for each ID. Each ID may actually be a
238240
// key in the array, with extra attributes to be placed in other columns.
239-
$attributes = $this->using
240-
? $this->newPivot()->forceFill($attributes)->getAttributes()
241-
: $attributes;
242-
243241
foreach ($ids as $key => $value) {
244242
$records[] = $this->formatAttachRecord(
245243
$key, $value, $attributes, $hasTimestamps
@@ -263,7 +261,7 @@ protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
263261
list($id, $attributes) = $this->extractAttachIdAndAttributes($key, $value, $attributes);
264262

265263
return array_merge(
266-
$this->baseAttachRecord($id, $hasTimestamps), $attributes
264+
$this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
267265
);
268266
}
269267

@@ -503,4 +501,17 @@ protected function castKey($key)
503501
{
504502
return is_numeric($key) ? (int) $key : (string) $key;
505503
}
504+
505+
/**
506+
* Cast the given pivot attributes.
507+
*
508+
* @param array $attributes
509+
* @return array
510+
*/
511+
protected function castAttributes($attributes)
512+
{
513+
return $this->using
514+
? $this->newPivot()->forceFill($attributes)->getAttributes()
515+
: $attributes;
516+
}
506517
}

src/Illuminate/Database/Eloquent/SoftDeletes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function runSoftDelete()
6666

6767
$this->{$this->getDeletedAtColumn()} = $time;
6868

69-
if ($this->timestamps) {
69+
if ($this->timestamps && ! is_null($this->getUpdatedAtColumn())) {
7070
$this->{$this->getUpdatedAtColumn()} = $time;
7171

7272
$columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
2929
*
3030
* @var string
3131
*/
32-
const VERSION = '5.5.7';
32+
const VERSION = '5.5.8';
3333

3434
/**
3535
* The base path for the Laravel installation.

src/Illuminate/Routing/RouteCollection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ public function match(Request $request)
189189
*/
190190
protected function matchAgainstRoutes(array $routes, $request, $includingMethod = true)
191191
{
192-
return collect($routes)->sortBy('isFallback')->first(function ($value) use ($request, $includingMethod) {
192+
list($fallbacks, $routes) = collect($routes)->partition(function ($route) {
193+
return $route->isFallback;
194+
});
195+
196+
return $routes->merge($fallbacks)->first(function ($value) use ($request, $includingMethod) {
193197
return $value->matches($request, $includingMethod);
194198
});
195199
}

src/Illuminate/Session/DatabaseSessionHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,16 @@ public function read($sessionId)
9393
if ($this->expired($session)) {
9494
$this->exists = true;
9595

96-
return;
96+
return '';
9797
}
9898

9999
if (isset($session->payload)) {
100100
$this->exists = true;
101101

102102
return base64_decode($session->payload);
103103
}
104+
105+
return '';
104106
}
105107

106108
/**

tests/Integration/Database/EloquentCustomPivotCastTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ public function test_casts_are_respected_on_attach()
6161
$this->assertEquals(['foo' => 'bar'], $project->collaborators[0]->pivot->permissions);
6262
}
6363

64+
public function test_casts_are_respected_on_attach_array()
65+
{
66+
$user = CustomPivotCastTestUser::forceCreate([
67+
'email' => '[email protected]',
68+
]);
69+
70+
$user2 = CustomPivotCastTestUser::forceCreate([
71+
'email' => '[email protected]',
72+
]);
73+
74+
$project = CustomPivotCastTestProject::forceCreate([
75+
'name' => 'Test Project',
76+
]);
77+
78+
$project->collaborators()->attach([
79+
$user->id => ['permissions' => ['foo' => 'bar']],
80+
$user2->id => ['permissions' => ['baz' => 'bar']],
81+
]);
82+
$project = $project->fresh();
83+
84+
$this->assertEquals(['foo' => 'bar'], $project->collaborators[0]->pivot->permissions);
85+
$this->assertEquals(['baz' => 'bar'], $project->collaborators[1]->pivot->permissions);
86+
}
87+
6488
public function test_casts_are_respected_on_sync()
6589
{
6690
$user = CustomPivotCastTestUser::forceCreate([
@@ -76,6 +100,60 @@ public function test_casts_are_respected_on_sync()
76100

77101
$this->assertEquals(['foo' => 'bar'], $project->collaborators[0]->pivot->permissions);
78102
}
103+
104+
public function test_casts_are_respected_on_sync_array()
105+
{
106+
$user = CustomPivotCastTestUser::forceCreate([
107+
'email' => '[email protected]',
108+
]);
109+
110+
$user2 = CustomPivotCastTestUser::forceCreate([
111+
'email' => '[email protected]',
112+
]);
113+
114+
$project = CustomPivotCastTestProject::forceCreate([
115+
'name' => 'Test Project',
116+
]);
117+
118+
$project->collaborators()->sync([
119+
$user->id => ['permissions' => ['foo' => 'bar']],
120+
$user2->id => ['permissions' => ['baz' => 'bar']],
121+
]);
122+
$project = $project->fresh();
123+
124+
$this->assertEquals(['foo' => 'bar'], $project->collaborators[0]->pivot->permissions);
125+
$this->assertEquals(['baz' => 'bar'], $project->collaborators[1]->pivot->permissions);
126+
}
127+
128+
public function test_casts_are_respected_on_sync_array_while_updating_existing()
129+
{
130+
$user = CustomPivotCastTestUser::forceCreate([
131+
'email' => '[email protected]',
132+
]);
133+
134+
$user2 = CustomPivotCastTestUser::forceCreate([
135+
'email' => '[email protected]',
136+
]);
137+
138+
$project = CustomPivotCastTestProject::forceCreate([
139+
'name' => 'Test Project',
140+
]);
141+
142+
$project->collaborators()->attach([
143+
$user->id => ['permissions' => ['foo' => 'bar']],
144+
$user2->id => ['permissions' => ['baz' => 'bar']],
145+
]);
146+
147+
$project->collaborators()->sync([
148+
$user->id => ['permissions' => ['foo1' => 'bar1']],
149+
$user2->id => ['permissions' => ['baz2' => 'bar2']],
150+
]);
151+
152+
$project = $project->fresh();
153+
154+
$this->assertEquals(['foo1' => 'bar1'], $project->collaborators[0]->pivot->permissions);
155+
$this->assertEquals(['baz2' => 'bar2'], $project->collaborators[1]->pivot->permissions);
156+
}
79157
}
80158

81159
class CustomPivotCastTestUser extends Model

tests/Integration/Routing/FallbackRouteTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,36 @@ public function test_fallback_with_wildcards()
4949
return response('fallback', 404);
5050
});
5151

52+
Route::get('one', function () {
53+
return 'one';
54+
});
55+
5256
Route::get('{any}', function () {
5357
return 'wildcard';
5458
})->where('any', '.*');
5559

60+
$this->assertContains('one', $this->get('/one')->getContent());
61+
$this->assertContains('wildcard', $this->get('/non-existing')->getContent());
62+
$this->assertEquals(200, $this->get('/non-existing')->getStatusCode());
63+
}
64+
65+
public function test_no_routes()
66+
{
67+
Route::fallback(function () {
68+
return response('fallback', 404);
69+
});
70+
71+
$this->assertContains('fallback', $this->get('/non-existing')->getContent());
72+
$this->assertEquals(404, $this->get('/non-existing')->getStatusCode());
73+
}
74+
75+
public function test_no_fallbacks()
76+
{
5677
Route::get('one', function () {
5778
return 'one';
5879
});
5980

6081
$this->assertContains('one', $this->get('/one')->getContent());
61-
$this->assertContains('wildcard', $this->get('/non-existing')->getContent());
62-
$this->assertEquals(200, $this->get('/non-existing')->getStatusCode());
82+
$this->assertEquals(200, $this->get('/one')->getStatusCode());
6383
}
6484
}

0 commit comments

Comments
 (0)