Skip to content

Commit 1cdf4d9

Browse files
committed
Merge remote-tracking branch 'upstream/8.x' into 8.x
2 parents bf3092a + 041f016 commit 1cdf4d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1142
-95
lines changed

src/Illuminate/Auth/SessionGuard.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
1818
use Illuminate\Contracts\Events\Dispatcher;
1919
use Illuminate\Contracts\Session\Session;
20+
use Illuminate\Support\Arr;
2021
use Illuminate\Support\Facades\Hash;
2122
use Illuminate\Support\Str;
2223
use Illuminate\Support\Traits\Macroable;
@@ -374,6 +375,34 @@ public function attempt(array $credentials = [], $remember = false)
374375
return false;
375376
}
376377

378+
/**
379+
* Attempt to authenticate a user with credentials and additional callbacks.
380+
*
381+
* @param array $credentials
382+
* @param array|callable $callbacks
383+
* @param false $remember
384+
* @return bool
385+
*/
386+
public function attemptWhen(array $credentials = [], $callbacks = null, $remember = false)
387+
{
388+
$this->fireAttemptEvent($credentials, $remember);
389+
390+
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
391+
392+
// This method does the exact same thing as attempt, but also executes callbacks after
393+
// the user is retrieved and validated. If one of the callbacks returns falsy we do
394+
// not login the user. Instead, we will fail the specific authentication attempt.
395+
if ($this->hasValidCredentials($user, $credentials) && $this->shouldLogin($callbacks, $user)) {
396+
$this->login($user, $remember);
397+
398+
return true;
399+
}
400+
401+
$this->fireFailedEvent($user, $credentials);
402+
403+
return false;
404+
}
405+
377406
/**
378407
* Determine if the user matches the credentials.
379408
*
@@ -392,6 +421,24 @@ protected function hasValidCredentials($user, $credentials)
392421
return $validated;
393422
}
394423

424+
/**
425+
* Determine if the user should login by executing the given callbacks.
426+
*
427+
* @param array|callable|null $callbacks
428+
* @param \Illuminate\Contracts\Auth\Authenticatable $user
429+
* @return bool
430+
*/
431+
protected function shouldLogin($callbacks, AuthenticatableContract $user)
432+
{
433+
foreach (Arr::wrap($callbacks) as $callback) {
434+
if (! $callback($user, $this)) {
435+
return false;
436+
}
437+
}
438+
439+
return true;
440+
}
441+
395442
/**
396443
* Log the given user ID into the application.
397444
*

src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ class RedisBroadcaster extends Broadcaster
2020
/**
2121
* The Redis connection to use for broadcasting.
2222
*
23-
* @var string
23+
* @var ?string
2424
*/
25-
protected $connection;
25+
protected $connection = null;
2626

2727
/**
2828
* The Redis key prefix.
2929
*
3030
* @var string
3131
*/
32-
protected $prefix;
32+
protected $prefix = '';
3333

3434
/**
3535
* Create a new broadcaster instance.

src/Illuminate/Cache/Console/ClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function cache()
116116
*/
117117
protected function tags()
118118
{
119-
return array_filter(explode(',', $this->option('tags')));
119+
return array_filter(explode(',', $this->option('tags') ?? ''));
120120
}
121121

122122
/**

src/Illuminate/Collections/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ public function implode($value, $glue = null)
515515
$first = $this->first();
516516

517517
if (is_array($first) || (is_object($first) && ! $first instanceof Stringable)) {
518-
return implode($glue, $this->pluck($value)->all());
518+
return implode($glue ?? '', $this->pluck($value)->all());
519519
}
520520

521-
return implode($value, $this->items);
521+
return implode($value ?? '', $this->items);
522522
}
523523

524524
/**

src/Illuminate/Console/Scheduling/ScheduleListCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public function handle(Schedule $schedule)
3737
$event->expression,
3838
$event->description,
3939
(new CronExpression($event->expression))
40-
->getNextRunDate(Carbon::now())
41-
->setTimezone($this->option('timezone', config('app.timezone'))),
40+
->getNextRunDate(Carbon::now()->setTimezone($event->timezone))
41+
->setTimezone($this->option('timezone', config('app.timezone')))
42+
->format('Y-m-d H:i:s P'),
4243
];
4344
}
4445

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Illuminate\Contracts\Validation;
4+
5+
interface DataAwareRule
6+
{
7+
/**
8+
* Set the data under validation.
9+
*
10+
* @param array $data
11+
* @return $this
12+
*/
13+
public function setData($data);
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Illuminate\Contracts\Validation;
4+
5+
interface UncompromisedVerifier
6+
{
7+
/**
8+
* Verify that the given data has not been compromised in data leaks.
9+
*
10+
* @param array $data
11+
* @return bool
12+
*/
13+
public function verify($data);
14+
}

src/Illuminate/Cookie/CookieJar.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@ public function queue(...$parameters)
153153
$this->queued[$cookie->getName()][$cookie->getPath()] = $cookie;
154154
}
155155

156+
/**
157+
* Queue a cookie to expire with the next response.
158+
*
159+
* @param string $name
160+
* @param string|null $path
161+
* @param string|null $domain
162+
* @return void
163+
*/
164+
public function expire($name, $path = null, $domain = null)
165+
{
166+
$this->queue($this->forget($name, $path, $domain));
167+
}
168+
156169
/**
157170
* Remove a cookie from the queue.
158171
*

src/Illuminate/Database/Eloquent/Relations/MorphTo.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,14 @@ protected function matchToMorphParents($type, Collection $results)
231231
*/
232232
public function associate($model)
233233
{
234+
if ($model instanceof Model) {
235+
$foreignKey = $this->ownerKey && $model->{$this->ownerKey}
236+
? $this->ownerKey
237+
: $model->getKeyName();
238+
}
239+
234240
$this->parent->setAttribute(
235-
$this->foreignKey, $model instanceof Model ? $model->{$this->ownerKey ?: $model->getKeyName()} : null
241+
$this->foreignKey, $model instanceof Model ? $model->{$foreignKey} : null
236242
);
237243

238244
$this->parent->setAttribute(

src/Illuminate/Database/Eloquent/SoftDeletes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withTrashed(bool $withTrashed = true)
77
* @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder onlyTrashed()
88
* @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder withoutTrashed()
9-
* @method static static|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder restore()
109
*/
1110
trait SoftDeletes
1211
{

0 commit comments

Comments
 (0)