Skip to content

Commit

Permalink
Merge branch '11.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed May 21, 2024
2 parents f22eaf2 + 41409f4 commit a7d3d29
Show file tree
Hide file tree
Showing 61 changed files with 381 additions and 94 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: update changelog

on:
release:
types: [released]

jobs:
update:
uses: laravel/.github/.github/workflows/update-changelog.yml@main
10 changes: 9 additions & 1 deletion config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => null,
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
Expand Down Expand Up @@ -87,6 +87,14 @@
],
],

'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
],

],

/*
Expand Down
4 changes: 4 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],

'resend' => [
'key' => env('RESEND_KEY'),
],

'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" since this is a secure default value.
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
Expand Down
13 changes: 12 additions & 1 deletion src/Illuminate/Cache/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,18 @@ public function owner()
*/
public function isOwnedByCurrentProcess()
{
return $this->getCurrentOwner() === $this->owner;
return $this->isOwnedBy($this->owner);
}

/**
* Determine whether this lock is owned by the given identifier.
*
* @param string|null $owner
* @return bool
*/
public function isOwnedBy($owner)
{
return $this->getCurrentOwner() === $owner;
}

/**
Expand Down
19 changes: 0 additions & 19 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,6 @@ public function lazy()
return new LazyCollection($this->items);
}

/**
* Get the average value of a given key.
*
* @param (callable(TValue): float|int)|string|null $callback
* @return float|int|null
*/
public function avg($callback = null)
{
$callback = $this->valueRetriever($callback);

$items = $this
->map(fn ($value) => $callback($value))
->filter(fn ($value) => ! is_null($value));

if ($count = $items->count()) {
return $items->sum() / $count;
}
}

/**
* Get the median of a given key.
*
Expand Down
11 changes: 0 additions & 11 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,6 @@ public function remember()
});
}

/**
* Get the average value of a given key.
*
* @param (callable(TValue): float|int)|string|null $callback
* @return float|int|null
*/
public function avg($callback = null)
{
return $this->collect()->avg($callback);
}

/**
* Get the median of a given key.
*
Expand Down
22 changes: 22 additions & 0 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@ public static function times($number, ?callable $callback = null)
->map($callback);
}

/**
* Get the average value of a given key.
*
* @param (callable(TValue): float|int)|string|null $callback
* @return float|int|null
*/
public function avg($callback = null)
{
$callback = $this->valueRetriever($callback);

$reduced = $this->reduce(static function (&$reduce, $value) use ($callback) {
if (! is_null($resolved = $callback($value))) {
$reduce[0] += $resolved;
$reduce[1]++;
}

return $reduce;
}, [0, 0]);

return $reduced[1] ? $reduced[0] / $reduced[1] : null;
}

/**
* Alias for the "avg" method.
*
Expand Down
24 changes: 24 additions & 0 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

class Command extends SymfonyCommand
{
Expand Down Expand Up @@ -210,6 +211,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int

try {
return (int) $this->laravel->call([$this, $method]);
} catch (ManuallyFailedException $e) {
$this->components->error($e->getMessage());

return static::FAILURE;
} finally {
if ($this instanceof Isolatable && $this->option('isolated') !== false) {
$this->commandIsolationMutex()->forget($this);
Expand Down Expand Up @@ -254,6 +259,25 @@ protected function resolveCommand($command)
return $command;
}

/**
* Fail the command manually.
*
* @param \Throwable|string|null $exception
* @return void
*/
public function fail(Throwable|string|null $exception = null)
{
if (is_null($exception)) {
$exception = 'Command failed manually.';
}

if (is_string($exception)) {
$exception = new ManuallyFailedException($exception);
}

throw $exception;
}

/**
* {@inheritdoc}
*
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Console/ManuallyFailedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Illuminate\Console;

use RuntimeException;

class ManuallyFailedException extends RuntimeException
{
//
}
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function createPdoConnection($dsn, $username, $password, $options)
* @param array $options
* @return \PDO
*
* @throws \Exception
* @throws \Throwable
*/
protected function tryAgainIfCausedByLostConnection(Throwable $e, $dsn, $username, $password, $options)
{
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Illuminate\Database\UniqueConstraintViolationException;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
use ReflectionClass;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Concerns/HasUlids.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function newUniqueId()
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Query\Builder
* @return \Illuminate\Contracts\Database\Eloquent\Builder
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Concerns/HasUuids.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function newUniqueId()
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Query\Builder
* @return \Illuminate\Contracts\Database\Eloquent\Builder
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ protected function childRouteBindingRelationshipName($childType)
* @param \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Relations\Relation $query
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Query\Builder
* @return \Illuminate\Contracts\Database\Eloquent\Builder
*/
public function resolveRouteBindingQuery($query, $value, $field = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ public function addNestedWhereQuery($query, $boolean = 'and')
*
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
* @param string $operator
* @param \Closure||\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $callback
* @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $callback
* @param string $boolean
* @return $this
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function getColumnType($table, $column, $fullDefinition = false)
$columns = $this->getColumns($table);

foreach ($columns as $value) {
if (strtolower($value['name']) === $column) {
if (strtolower($value['name']) === strtolower($column)) {
return $fullDefinition ? $value['type'] : $value['type_name'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public function withRouting(?Closure $using = null,
* @param callable|null $then
* @return \Closure
*/
protected function buildRoutingCallback(array|string|null $web = null,
array|string|null $api = null,
protected function buildRoutingCallback(array|string|null $web,
array|string|null $api,
?string $pages,
?string $health,
string $apiPrefix,
Expand Down
13 changes: 10 additions & 3 deletions src/Illuminate/Foundation/Console/ClosureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Console\Command;
use Illuminate\Console\ManuallyFailedException;
use Illuminate\Support\Facades\Schedule;
use Illuminate\Support\Traits\ForwardsCalls;
use ReflectionFunction;
Expand Down Expand Up @@ -58,9 +59,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

return (int) $this->laravel->call(
$this->callback->bindTo($this, $this), $parameters
);
try {
return (int) $this->laravel->call(
$this->callback->bindTo($this, $this), $parameters
);
} catch (ManuallyFailedException $e) {
$this->components->error($e->getMessage());

return static::FAILURE;
}
}

/**
Expand Down
Loading

0 comments on commit a7d3d29

Please sign in to comment.