Skip to content

Commit 745d813

Browse files
committed
Merge branch '10.x'
2 parents 03e13ca + 6d690ed commit 745d813

Some content is hidden

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

48 files changed

+1327
-109
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- 6379:6379
3333
options: --entrypoint redis-server
3434
dynamodb:
35-
image: amazon/dynamodb-local:latest
35+
image: amazon/dynamodb-local:2.0.0
3636
ports:
3737
- 8888:8000
3838

@@ -82,8 +82,8 @@ jobs:
8282
DB_USERNAME: root
8383
DYNAMODB_CACHE_TABLE: laravel_dynamodb_test
8484
DYNAMODB_ENDPOINT: "http://localhost:8888"
85-
AWS_ACCESS_KEY_ID: random_key
86-
AWS_SECRET_ACCESS_KEY: random_secret
85+
AWS_ACCESS_KEY_ID: randomKey
86+
AWS_SECRET_ACCESS_KEY: randomSecret
8787

8888
- name: Store artifacts
8989
uses: actions/upload-artifact@v3

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
33
dynamodb:
4-
image: amazon/dynamodb-local
4+
image: amazon/dynamodb-local:2.0.0
55
ports:
66
- "8000:8000"
77
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-inMemory"]

src/Illuminate/Auth/Passwords/PasswordBroker.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public function sendResetLink(array $credentials, Closure $callback = null)
6363
$token = $this->tokens->create($user);
6464

6565
if ($callback) {
66-
$callback($user, $token);
67-
} else {
68-
// Once we have the reset token, we are ready to send the message out to this
69-
// user with a link to reset their password. We will then redirect back to
70-
// the current URI having nothing set in the session to indicate errors.
71-
$user->sendPasswordResetNotification($token);
66+
return $callback($user, $token) ?? static::RESET_LINK_SENT;
7267
}
7368

69+
// Once we have the reset token, we are ready to send the message out to this
70+
// user with a link to reset their password. We will then redirect back to
71+
// the current URI having nothing set in the session to indicate errors.
72+
$user->sendPasswordResetNotification($token);
73+
7474
return static::RESET_LINK_SENT;
7575
}
7676

src/Illuminate/Broadcasting/Broadcasters/AblyBroadcaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ protected function getPublicToken()
216216
/**
217217
* Get the private token value from the Ably key.
218218
*
219-
* @return mixed
219+
* @return string
220220
*/
221221
protected function getPrivateToken()
222222
{

src/Illuminate/Collections/Collection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,13 @@ public function flip()
424424
/**
425425
* Remove an item from the collection by key.
426426
*
427-
* @param TKey|array<array-key, TKey> $keys
427+
* \Illuminate\Contracts\Support\Arrayable<array-key, TValue>|iterable<array-key, TKey>|TKey $keys
428+
*
428429
* @return $this
429430
*/
430431
public function forget($keys)
431432
{
432-
foreach ((array) $keys as $key) {
433+
foreach ($this->getArrayableItems($keys) as $key) {
433434
$this->offsetUnset($key);
434435
}
435436

src/Illuminate/Console/Scheduling/Event.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class Event
3838
*/
3939
public $expression = '* * * * *';
4040

41+
/**
42+
* How often to repeat the event during a minute.
43+
*
44+
* @var int|null
45+
*/
46+
public $repeatSeconds = null;
47+
4148
/**
4249
* The timezone the date should be evaluated on.
4350
*
@@ -157,6 +164,15 @@ class Event
157164
*/
158165
public $mutexNameResolver;
159166

167+
/**
168+
* The last time the event was checked for eligibility to run.
169+
*
170+
* Utilized by sub-minute repeated events.
171+
*
172+
* @var \Illuminate\Support\Carbon|null
173+
*/
174+
protected $lastChecked;
175+
160176
/**
161177
* The exit status code of the command.
162178
*
@@ -222,6 +238,27 @@ public function shouldSkipDueToOverlapping()
222238
return $this->withoutOverlapping && ! $this->mutex->create($this);
223239
}
224240

241+
/**
242+
* Determine if the event has been configured to repeat multiple times per minute.
243+
*
244+
* @return bool
245+
*/
246+
public function isRepeatable()
247+
{
248+
return ! is_null($this->repeatSeconds);
249+
}
250+
251+
/**
252+
* Determine if the event is ready to repeat.
253+
*
254+
* @return bool
255+
*/
256+
public function shouldRepeatNow()
257+
{
258+
return $this->isRepeatable()
259+
&& $this->lastChecked?->diffInSeconds() >= $this->repeatSeconds;
260+
}
261+
225262
/**
226263
* Run the command process.
227264
*
@@ -371,6 +408,8 @@ public function runsInEnvironment($environment)
371408
*/
372409
public function filtersPass($app)
373410
{
411+
$this->lastChecked = Date::now();
412+
374413
foreach ($this->filters as $callback) {
375414
if (! $app->call($callback)) {
376415
return false;

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\Console\Scheduling;
44

55
use Illuminate\Support\Carbon;
6+
use InvalidArgumentException;
67

78
trait ManagesFrequencies
89
{
@@ -69,6 +70,93 @@ private function inTimeInterval($startTime, $endTime)
6970
return fn () => $now->between($startTime, $endTime);
7071
}
7172

73+
/**
74+
* Schedule the event to run every second.
75+
*
76+
* @return $this
77+
*/
78+
public function everySecond()
79+
{
80+
return $this->repeatEvery(1);
81+
}
82+
83+
/**
84+
* Schedule the event to run every two seconds.
85+
*
86+
* @return $this
87+
*/
88+
public function everyTwoSeconds()
89+
{
90+
return $this->repeatEvery(2);
91+
}
92+
93+
/**
94+
* Schedule the event to run every five seconds.
95+
*
96+
* @return $this
97+
*/
98+
public function everyFiveSeconds()
99+
{
100+
return $this->repeatEvery(5);
101+
}
102+
103+
/**
104+
* Schedule the event to run every ten seconds.
105+
*
106+
* @return $this
107+
*/
108+
public function everyTenSeconds()
109+
{
110+
return $this->repeatEvery(10);
111+
}
112+
113+
/**
114+
* Schedule the event to run every fifteen seconds.
115+
*
116+
* @return $this
117+
*/
118+
public function everyFifteenSeconds()
119+
{
120+
return $this->repeatEvery(15);
121+
}
122+
123+
/**
124+
* Schedule the event to run every twenty seconds.
125+
*
126+
* @return $this
127+
*/
128+
public function everyTwentySeconds()
129+
{
130+
return $this->repeatEvery(20);
131+
}
132+
133+
/**
134+
* Schedule the event to run every thirty seconds.
135+
*
136+
* @return $this
137+
*/
138+
public function everyThirtySeconds()
139+
{
140+
return $this->repeatEvery(30);
141+
}
142+
143+
/**
144+
* Schedule the event to run multiple times per minute.
145+
*
146+
* @param int $seconds
147+
* @return $this
148+
*/
149+
protected function repeatEvery($seconds)
150+
{
151+
if (60 % $seconds !== 0) {
152+
throw new InvalidArgumentException("The seconds [$seconds] are not evenly divisible by 60.");
153+
}
154+
155+
$this->repeatSeconds = $seconds;
156+
157+
return $this->everyMinute();
158+
}
159+
72160
/**
73161
* Schedule the event to run every minute.
74162
*

src/Illuminate/Console/Scheduling/Schedule.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class Schedule
7070
*/
7171
protected $dispatcher;
7272

73+
/**
74+
* The cache of mutex results.
75+
*
76+
* @var array<string, bool>
77+
*/
78+
protected $mutexCache = [];
79+
7380
/**
7481
* Create a new schedule instance.
7582
*
@@ -299,7 +306,7 @@ public function compileArrayInput($key, $value)
299306
*/
300307
public function serverShouldRun(Event $event, DateTimeInterface $time)
301308
{
302-
return $this->schedulingMutex->create($event, $time);
309+
return $this->mutexCache[$event->mutexName()] ??= $this->schedulingMutex->create($event, $time);
303310
}
304311

305312
/**
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Illuminate\Console\Scheduling;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Contracts\Cache\Repository as Cache;
7+
use Illuminate\Support\Facades\Date;
8+
use Symfony\Component\Console\Attribute\AsCommand;
9+
10+
#[AsCommand(name: 'schedule:interrupt')]
11+
class ScheduleInterruptCommand extends Command
12+
{
13+
/**
14+
* The console command name.
15+
*
16+
* @var string
17+
*/
18+
protected $name = 'schedule:interrupt';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Interrupt the current schedule run';
26+
27+
/**
28+
* The cache store implementation.
29+
*
30+
* @var \Illuminate\Contracts\Cache\Repository
31+
*/
32+
protected $cache;
33+
34+
/**
35+
* Create a new schedule interrupt command.
36+
*
37+
* @param \Illuminate\Contracts\Cache\Repository $cache
38+
* @return void
39+
*/
40+
public function __construct(Cache $cache)
41+
{
42+
parent::__construct();
43+
44+
$this->cache = $cache;
45+
}
46+
47+
/**
48+
* Execute the console command.
49+
*
50+
* @return void
51+
*/
52+
public function handle()
53+
{
54+
$this->cache->put('illuminate:schedule:interrupt', true, Date::now()->endOfMinute());
55+
56+
$this->components->info('Broadcasting schedule interrupt signal.');
57+
}
58+
}

0 commit comments

Comments
 (0)