Skip to content

Commit e5646d9

Browse files
authored
Merge branch 'laravel:9.x' into 9.x
2 parents 89c093f + bb071a9 commit e5646d9

24 files changed

+333
-29
lines changed

src/Illuminate/Bus/PendingBatch.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public function __construct(Container $container, Collection $jobs)
5757
/**
5858
* Add jobs to the batch.
5959
*
60-
* @param \Illuminate\Support\Enumerable|object|array $jobs
60+
* @param iterable|object|array $jobs
6161
* @return $this
6262
*/
6363
public function add($jobs)
6464
{
65-
foreach (Arr::wrap($jobs) as $job) {
65+
$jobs = is_iterable($jobs) ? $jobs : Arr::wrap($jobs);
66+
67+
foreach ($jobs as $job) {
6668
$this->jobs->push($job);
6769
}
6870

src/Illuminate/Cache/CacheLock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function acquire()
4646

4747
return ($this->seconds > 0)
4848
? $this->store->put($this->name, $this->owner, $this->seconds)
49-
: $this->store->forever($this->name, $this->owner, $this->seconds);
49+
: $this->store->forever($this->name, $this->owner);
5050
}
5151

5252
/**

src/Illuminate/Database/Schema/Blueprint.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ public function date($column)
10891089
* Create a new date-time column on the table.
10901090
*
10911091
* @param string $column
1092-
* @param int $precision
1092+
* @param int|null $precision
10931093
* @return \Illuminate\Database\Schema\ColumnDefinition
10941094
*/
10951095
public function dateTime($column, $precision = 0)
@@ -1101,7 +1101,7 @@ public function dateTime($column, $precision = 0)
11011101
* Create a new date-time column (with time zone) on the table.
11021102
*
11031103
* @param string $column
1104-
* @param int $precision
1104+
* @param int|null $precision
11051105
* @return \Illuminate\Database\Schema\ColumnDefinition
11061106
*/
11071107
public function dateTimeTz($column, $precision = 0)
@@ -1113,7 +1113,7 @@ public function dateTimeTz($column, $precision = 0)
11131113
* Create a new time column on the table.
11141114
*
11151115
* @param string $column
1116-
* @param int $precision
1116+
* @param int|null $precision
11171117
* @return \Illuminate\Database\Schema\ColumnDefinition
11181118
*/
11191119
public function time($column, $precision = 0)
@@ -1125,7 +1125,7 @@ public function time($column, $precision = 0)
11251125
* Create a new time column (with time zone) on the table.
11261126
*
11271127
* @param string $column
1128-
* @param int $precision
1128+
* @param int|null $precision
11291129
* @return \Illuminate\Database\Schema\ColumnDefinition
11301130
*/
11311131
public function timeTz($column, $precision = 0)
@@ -1137,7 +1137,7 @@ public function timeTz($column, $precision = 0)
11371137
* Create a new timestamp column on the table.
11381138
*
11391139
* @param string $column
1140-
* @param int $precision
1140+
* @param int|null $precision
11411141
* @return \Illuminate\Database\Schema\ColumnDefinition
11421142
*/
11431143
public function timestamp($column, $precision = 0)
@@ -1149,7 +1149,7 @@ public function timestamp($column, $precision = 0)
11491149
* Create a new timestamp (with time zone) column on the table.
11501150
*
11511151
* @param string $column
1152-
* @param int $precision
1152+
* @param int|null $precision
11531153
* @return \Illuminate\Database\Schema\ColumnDefinition
11541154
*/
11551155
public function timestampTz($column, $precision = 0)
@@ -1160,7 +1160,7 @@ public function timestampTz($column, $precision = 0)
11601160
/**
11611161
* Add nullable creation and update timestamps to the table.
11621162
*
1163-
* @param int $precision
1163+
* @param int|null $precision
11641164
* @return void
11651165
*/
11661166
public function timestamps($precision = 0)
@@ -1175,7 +1175,7 @@ public function timestamps($precision = 0)
11751175
*
11761176
* Alias for self::timestamps().
11771177
*
1178-
* @param int $precision
1178+
* @param int|null $precision
11791179
* @return void
11801180
*/
11811181
public function nullableTimestamps($precision = 0)
@@ -1186,7 +1186,7 @@ public function nullableTimestamps($precision = 0)
11861186
/**
11871187
* Add creation and update timestampTz columns to the table.
11881188
*
1189-
* @param int $precision
1189+
* @param int|null $precision
11901190
* @return void
11911191
*/
11921192
public function timestampsTz($precision = 0)
@@ -1200,7 +1200,7 @@ public function timestampsTz($precision = 0)
12001200
* Add a "deleted at" timestamp for the table.
12011201
*
12021202
* @param string $column
1203-
* @param int $precision
1203+
* @param int|null $precision
12041204
* @return \Illuminate\Database\Schema\ColumnDefinition
12051205
*/
12061206
public function softDeletes($column = 'deleted_at', $precision = 0)
@@ -1212,7 +1212,7 @@ public function softDeletes($column = 'deleted_at', $precision = 0)
12121212
* Add a "deleted at" timestampTz for the table.
12131213
*
12141214
* @param string $column
1215-
* @param int $precision
1215+
* @param int|null $precision
12161216
* @return \Illuminate\Database\Schema\ColumnDefinition
12171217
*/
12181218
public function softDeletesTz($column = 'deleted_at', $precision = 0)

src/Illuminate/Database/Schema/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Builder
3434
/**
3535
* The default string length for migrations.
3636
*
37-
* @var int
37+
* @var int|null
3838
*/
3939
public static $defaultStringLength = 255;
4040

src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,11 @@ public function escapeNames($names)
509509
*/
510510
protected function typeChar(Fluent $column)
511511
{
512-
return "char({$column->length})";
512+
if ($column->length) {
513+
return "char({$column->length})";
514+
}
515+
516+
return 'char';
513517
}
514518

515519
/**
@@ -520,7 +524,11 @@ protected function typeChar(Fluent $column)
520524
*/
521525
protected function typeString(Fluent $column)
522526
{
523-
return "varchar({$column->length})";
527+
if ($column->length) {
528+
return "varchar({$column->length})";
529+
}
530+
531+
return 'varchar';
524532
}
525533

526534
/**

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Http\Client;
44

5+
use Exception;
56
use GuzzleHttp\Client;
67
use GuzzleHttp\Cookie\CookieJar;
78
use GuzzleHttp\Exception\ConnectException;
@@ -707,15 +708,23 @@ public function send(string $method, string $url, array $options = [])
707708
return $this->makePromise($method, $url, $options);
708709
}
709710

710-
$shouldRetry = true;
711+
$shouldRetry = null;
711712

712713
return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
713714
try {
714715
return tap(new Response($this->sendRequest($method, $url, $options)), function ($response) use ($attempt, &$shouldRetry) {
715716
$this->populateResponse($response);
716717

718+
$this->dispatchResponseReceivedEvent($response);
719+
717720
if (! $response->successful()) {
718-
$shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException()) : true;
721+
try {
722+
$shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this) : true;
723+
} catch (Exception $exception) {
724+
$shouldRetry = false;
725+
726+
throw $exception;
727+
}
719728

720729
if ($attempt < $this->tries && $shouldRetry) {
721730
$response->throw();
@@ -725,16 +734,18 @@ public function send(string $method, string $url, array $options = [])
725734
$response->throw();
726735
}
727736
}
728-
729-
$this->dispatchResponseReceivedEvent($response);
730737
});
731738
} catch (ConnectException $e) {
732739
$this->dispatchConnectionFailedEvent();
733740

734741
throw new ConnectionException($e->getMessage(), 0, $e);
735742
}
736-
}, $this->retryDelay ?? 100, function () use (&$shouldRetry) {
737-
return $shouldRetry;
743+
}, $this->retryDelay ?? 100, function ($exception) use (&$shouldRetry) {
744+
$result = $shouldRetry ?? ($this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $exception, $this) : true);
745+
746+
$shouldRetry = null;
747+
748+
return $result;
738749
});
739750
}
740751

src/Illuminate/Queue/BeanstalkdQueue.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ function ($payload, $queue, $delay) {
136136
);
137137
}
138138

139+
/**
140+
* Push an array of jobs onto the queue.
141+
*
142+
* @param array $jobs
143+
* @param mixed $data
144+
* @param string|null $queue
145+
* @return void
146+
*/
147+
public function bulk($jobs, $data = '', $queue = null)
148+
{
149+
foreach ((array) $jobs as $job) {
150+
if (isset($job->delay)) {
151+
$this->later($job->delay, $job, $data, $queue);
152+
} else {
153+
$this->push($job, $data, $queue);
154+
}
155+
}
156+
}
157+
139158
/**
140159
* Pop the next job off of the queue.
141160
*

src/Illuminate/Queue/SqsQueue.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ function ($payload, $queue, $delay) {
141141
);
142142
}
143143

144+
/**
145+
* Push an array of jobs onto the queue.
146+
*
147+
* @param array $jobs
148+
* @param mixed $data
149+
* @param string|null $queue
150+
* @return void
151+
*/
152+
public function bulk($jobs, $data = '', $queue = null)
153+
{
154+
foreach ((array) $jobs as $job) {
155+
if (isset($job->delay)) {
156+
$this->later($job->delay, $job, $data, $queue);
157+
} else {
158+
$this->push($job, $data, $queue);
159+
}
160+
}
161+
}
162+
144163
/**
145164
* Pop the next job off of the queue.
146165
*

src/Illuminate/Routing/CreatesRegularExpressionRouteConstraints.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ public function whereUuid($parameters)
5050
return $this->assignExpressionToParameters($parameters, '[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}');
5151
}
5252

53+
/**
54+
* Specify that the given route parameters must be one of the given values.
55+
*
56+
* @param array|string $parameters
57+
* @param array $values
58+
* @return $this
59+
*/
60+
public function whereIn($parameters, array $values)
61+
{
62+
return $this->assignExpressionToParameters($parameters, implode('|', $values));
63+
}
64+
5365
/**
5466
* Apply the given regular expression to the given parameters.
5567
*

src/Illuminate/Support/Str.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,17 @@ public static function snake($value, $delimiter = '_')
881881
return static::$snakeCache[$key][$delimiter] = $value;
882882
}
883883

884+
/**
885+
* Remove all "extra" blank space from the given string.
886+
*
887+
* @param string $value
888+
* @return string
889+
*/
890+
public static function squish($value)
891+
{
892+
return preg_replace('/\s+/', ' ', trim($value));
893+
}
894+
884895
/**
885896
* Determine if a given string starts with a given substring.
886897
*

0 commit comments

Comments
 (0)