8000 Merge branch '8.x' · laravel/framework@d69e2e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d69e2e0

Browse files
committed
Merge branch '8.x'
# Conflicts: # CHANGELOG-8.x.md # src/Illuminate/Collections/Collection.php # src/Illuminate/Foundation/Application.php # src/Illuminate/Testing/TestResponse.php
2 parents 932e601 + e7f075f commit d69e2e0

38 files changed

+842
-74
lines changed

.github/SECURITY.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@
44

55
## Supported Versions
66

7-
Version | Security Fixes Until
8-
--- | ---
9-
8 | September 8th, 2021
10-
7 | March 3rd, 2021
11-
6 (LTS) | September 3rd, 2022
12-
5.8 | February 26th, 2020
13-
5.7 | September 4th, 2019
14-
5.6 | February 7th, 2019
15-
5.5 (LTS) | August 30th, 2020
7+
Please see [our support policy](https://laravel.com/docs/releases#support-policy) for information on supported versions for security releases.
168

179
## Reporting a Vulnerability
1810

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ jobs:
9191
matrix:
9292
php: ['8.0']
9393
stability: [prefer-lowest, prefer-stable]
94-
include:
95-
- php: '8.1'
96-
flags: "--ignore-platform-req=php"
97-
stability: prefer-stable
94+
# include:
95+
# - php: '8.1'
96+
# flags: "--ignore-platform-req=php"
97+
# stability: prefer-stable
9898

9999
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - Windows
100100

src/Illuminate/Auth/Notifications/ResetPassword.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,31 @@ public function via($notifiable)
5959
*/
6060
public function toMail($notifiable)
6161
{
62+
$url = $this->resetUrl($notifiable);
63+
6264
if (static::$toMailCallback) {
63-
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
65+
return call_user_func(static::$toMailCallback, $notifiable, $this->token, $url);
6466
}
6567

68+
return $this->buildMailMessage($url);
69+
}
70+
71+
/**
72+
* Get the password reset URL for the given notifiable.
73+
*
74+
* @param mixed $notifiable
75+
* @return string
76+
*/
77+
protected function resetUrl($notifiable)
78+
{
6679
if (static::$createUrlCallback) {
67-
$url = call_user_func(static::$createUrlCallback, $notifiable, $this->token);
80+
return call_user_func(static::$createUrlCallback, $notifiable, $this->token);
6881
} else {
69-
$url = url(route('password.reset', [
82+
return url(route('password.reset', [
7083
'token' => $this->token,
7184
'email' => $notifiable->getEmailForPasswordReset(),
7285
], false));
7386
}
74-
75-
return $this->buildMailMessage($url);
7687
}
7788

7889
/**

src/Illuminate/Broadcasting/BroadcastManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ public function event($event = null)
112112
*/
113113
public function queue($event)
114114
{
115-
if ($event instanceof ShouldBroadcastNow) {
115+
if ($event instanceof ShouldBroadcastNow ||
116+
(is_object($event) &&
117+
method_exists($event, 'shouldBroadcastNow') &&
118+
$event->shouldBroadcastNow())) {
116119
return $this->app->make(BusDispatcherContract::class)->dispatchNow(new BroadcastEvent(clone $event));
117120
}
118121

src/Illuminate/Collections/Collection.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,13 +1177,15 @@ public function firstOrFail($key = null, $operator = null, $value = null)
11771177
? $this->operatorForWhere(...func_get_args())
11781178
: $key;
11791179

1180-
$items = $this->unless($filter == null)->filter($filter);
1180+
$placeholder = new stdClass();
11811181

1182-
if ($items->isEmpty()) {
1182+
$item = $this->first($filter, $placeholder);
1183+
1184+
if ($item === $placeholder) {
11831185
throw new ItemNotFoundException;
11841186
}
11851187

1186-
return $items->first();
1188+
return $item;
11871189
}
11881190

11891191
/**

src/Illuminate/Contracts/Container/ContextualBindingBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function needs($abstract);
1515
/**
1616
* Define the implementation for the contextual binding.
1717
*
18-
* @param \Closure|string $implementation
18+
* @param \Closure|string|array $implementation
1919
* @return void
2020
*/
2121
public function give($implementation);

src/Illuminate/Database/Eloquent/BroadcastableModelEventOccurred.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ public function onChannels(array $channels)
114114
return $this;
115115
}
116116

117+
/**
118+
* Determine if the event should be broadcast synchronously.
119+
*
120+
* @return bool
121+
*/
122+
public function shouldBroadcastNow()
123+
{
124+
return $this->event === 'deleted' &&
125+
! method_exists($this->model, 'bootSoftDeletes');
126+
}
127+
117128
/**
118129
* Get the event name.
119130
*

src/Illuminate/Database/Eloquent/BroadcastsEvents.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public function broadcastDeleted($channels = null)
111111
*/
112112
protected function broadcastIfBroadcastChannelsExistForEvent($instance, $event, $channels = null)
113113
{
114+
if (! static::$isBroadcasting) {
115+
return;
116+
}
117+
114118
if (! empty($this->broadcastOn($event)) || ! empty($channels)) {
115119
return broadcast($instance->onChannels(Arr::wrap($channels)));
116120
}

src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,72 @@ public function orWhereDoesntHaveMorph($relation, $types, Closure $callback = nu
348348
return $this->doesntHaveMorph($relation, $types, 'or', $callback);
349349
}
350350

351+
/**
352+
* Add a basic where clause to a relationship query.
353+
*
354+
* @param string $relation
355+
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
356+
* @param mixed $operator
357+
* @param mixed $value
358+
* @return \Illuminate\Database\Eloquent\Builder|static
359+
*/
360+
public function whereRelation($relation, $column, $operator = null, $value = null)
361+
{
362+
return $this->whereHas($relation, function ($query) use ($column, $operator, $value) {
363+
$query->where($column, $operator, $value);
364+
});
365+
}
366+
367+
/**
368+
* Add an "or where" clause to a relationship query.
369+
*
370+
* @param string $relation
371+
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
372+
* @param mixed $operator
373+
* @param mixed $value
374+
* @return \Illuminate\Database\Eloquent\Builder|static
375+
*/
376+
public function orWhereRelation($relation, $column, $operator = null, $val 10000 ue = null)
377+
{
378+
return $this->orWhereHas($relation, function ($query) use ($column, $operator, $value) {
379+
$query->where($column, $operator, $value);
380+
});
381+
}
382+
383+
/**
384+
* Add a polymorphic relationship condition to the query with a where clause.
385+
*
386+
* @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation
387+
* @param string|array $types
388+
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
389+
* @param mixed $operator
390+
* @param mixed $value
391+
* @return \Illuminate\Database\Eloquent\Builder|static
392+
*/
393+
public function whereMorphRelation($relation, $types, $column, $operator = null, $value = null)
394+
{
395+
return $this->whereHasMorph($relation, $types, function ($query) use ($column, $operator, $value) {
396+
$query->where($column, $operator, $value);
397+
});
398+
}
399+
400+
/**
401+
* Add a polymorphic relationship condition to the query with an "or where" clause.
402+
*
403+
* @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation
404+
* @param string|array $types
405+
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
406+
* @param mixed $operator
407+
* @param mixed $value
408+
* @return \Illuminate\Database\Eloquent\Builder|static
409+
*/
410+
public function orWhereMorphRelation($relation, $types, $column, $operator = null, $value = null)
411+
{
412+
return $this->orWhereHasMorph($relation, $types, function ($query) use ($column, $operator, $value) {
413+
$query->where($column, $operator, $value);
414+
});
415+
}
416+
351417
/**
352418
* Add subselect queries to include an aggregate value for a relationship.
353419
*

src/Illuminate/Database/Eloquent/Factories/Factory.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ public function createOne($attributes = [])
202202
return $this->count(null)->create($attributes);
203203
}
204204

205+
/**
206+
* Create a single model and persist it to the database.
207+
*
208+
* @param array $attributes
209+
* @return \Illuminate\Database\Eloquent\Model
210+
*/
211+
public function createOneQuietly($attributes = [])
212+
{
213+
return $this->count(null)->createQuietly($attributes);
214+
}
215+
205216
/**
206217
* Create a collection of models and persist them to the database.
207218
*
@@ -217,6 +228,19 @@ public function createMany(iterable $records)
217228
);
218229
}
219230

231+
/**
232+
* Create a collection of models and persist them to the database.
233+
*
234+
* @param iterable $records
235+
* @return \Illuminate\Database\Eloquent\Collection
236+
*/
237+
public function createManyQuietly(iterable $records)
238+
{
239+
return Model::withoutEvents(function () use ($records) {
240+
return $this->createMany($records);
241+
});
242+
}
243+
220244
/**
221245
* Create a collection of models and persist them to the database.
222246
*
@@ -245,6 +269,20 @@ public function create($attributes = [], ?Model $parent = null)
245269
return $results;
246270
}
247271

272+
/**
273+
* Create a collection of models and persist them to the database.
274+
*
275+
* @param array $attributes
276+
* @param \Illuminate\Database\Eloquent\Model|null $parent
277+
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
278+
*/
279+
public function createQuietly($attributes = [], ?Model $parent = null)
280+
{
281+
return Model::withoutEvents(function () use ($attributes, $parent) {
282+
return $this->create($attributes, $parent);
283+
});
284+
}
285+
248286
/**
249287
* Create a callback that persists a model in the database when invoked.
250288
*

0 commit comments

Comments
 (0)
0