Skip to content

Commit

Permalink
Merge tag 'v11.38.1'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jan 14, 2025
2 parents 70bbb85 + 297652d commit ba17f0d
Show file tree
Hide file tree
Showing 66 changed files with 1,909 additions and 185 deletions.
38 changes: 37 additions & 1 deletion src/Illuminate/Broadcasting/BroadcastEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public function handle(BroadcastingFactory $manager)

foreach ($connections as $connection) {
$manager->connection($connection)->broadcast(
$channels, $name, $payload
$this->getConnectionChannels($channels, $connection),
$name,
$this->getConnectionPayload($payload, $connection)
);
}
}
Expand Down Expand Up @@ -134,6 +136,40 @@ protected function formatProperty($value)
return $value;
}

/**
* Get the channels for the given connection.
*
* @param array $channels
* @param string $connection
* @return array
*/
protected function getConnectionChannels($channels, $connection)
{
return is_array($channels[$connection] ?? null)
? $channels[$connection]
: $channels;
}

/**
* Get the payload for the given connection.
*
* @param array $payload
* @param string $connection
* @return array
*/
protected function getConnectionPayload($payload, $connection)
{
$connectionPayload = is_array($payload[$connection] ?? null)
? $payload[$connection]
: $payload;

if (isset($payload['socket'])) {
$connectionPayload['socket'] = $payload['socket'];
}

return $connectionPayload;
}

/**
* Get the display name for the queued job.
*
Expand Down
9 changes: 7 additions & 2 deletions src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\QueryException;
use Illuminate\Database\SQLiteConnection;
use Illuminate\Database\SqlServerConnection;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -487,7 +488,9 @@ protected function serialize($value)
{
$result = serialize($value);

if ($this->connection instanceof PostgresConnection && str_contains($result, "\0")) {
if (($this->connection instanceof PostgresConnection ||
$this->connection instanceof SQLiteConnection) &&
str_contains($result, "\0")) {
$result = base64_encode($result);
}

Expand All @@ -502,7 +505,9 @@ protected function serialize($value)
*/
protected function unserialize($value)
{
if ($this->connection instanceof PostgresConnection && ! Str::contains($value, [':', ';'])) {
if (($this->connection instanceof PostgresConnection ||
$this->connection instanceof SQLiteConnection) &&
! Str::contains($value, [':', ';'])) {
$value = base64_decode($value);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;

use function Illuminate\Support\artisan_binary;
use function Illuminate\Support\php_binary;

class Application extends SymfonyApplication implements ApplicationContract
Expand Down Expand Up @@ -95,7 +96,7 @@ public static function phpBinary()
*/
public static function artisanBinary()
{
return ProcessUtils::escapeArgument(defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan');
return ProcessUtils::escapeArgument(artisan_binary());
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ public function write(string|iterable $messages, bool $newline = false, int $opt
#[\Override]
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL): void
{
$this->newLinesWritten = $this->trailingNewLineCount($messages) + 1;
$this->newLineWritten = true;
if ($this->output->getVerbosity() >= $type) {
$this->newLinesWritten = $this->trailingNewLineCount($messages) + 1;
$this->newLineWritten = true;
}

parent::writeln($messages, $type);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function hourly()
/**
* Schedule the event to run hourly at a given offset in the hour.
*
* @param array|string|int<0, 23>|int<0, 23>[] $offset
* @param array|string|int<0, 59>|int<0, 59>[] $offset
* @return $this
*/
public function hourlyAt($offset)
Expand Down
6 changes: 4 additions & 2 deletions src/Illuminate/Console/Scheduling/ScheduleRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ public function handle(Schedule $schedule, Dispatcher $dispatcher, Cache $cache,
$this->handler = $handler;
$this->phpBinary = Application::phpBinary();

$this->clearInterruptSignal();

$this->newLine();

$events = $this->schedule->dueEvents($this->laravel);

if ($events->contains->isRepeatable()) {
$this->clearInterruptSignal();
}

foreach ($events as $event) {
if (! $event->filtersPass($this->laravel)) {
$this->dispatcher->dispatch(new ScheduledTaskSkipped($event));
Expand Down
14 changes: 7 additions & 7 deletions src/Illuminate/Contracts/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
interface Pipeline
{
/**
* Set the traveler object being sent on the pipeline.
* Set the object being sent through the pipeline.
*
* @param mixed $traveler
* @param mixed $passable
* @return $this
*/
public function send($traveler);
public function send($passable);

/**
* Set the stops of the pipeline.
* Set the array of pipes.
*
* @param dynamic|array $stops
* @param array|mixed $pipes
* @return $this
*/
public function through($stops);
public function through($pipes);

/**
* Set the method to call on the stops.
* Set the method to call on the pipes.
*
* @param string $method
* @return $this
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Connectors/MySqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function connect(array $config)
// connection's behavior, and some might be specified by the developers.
$connection = $this->createConnection($dsn, $config, $options);

if (! empty($config['database'])) {
if (! empty($config['database']) &&
(! isset($config['use_db_after_connecting']) ||
$config['use_db_after_connecting'])) {
$connection->exec("use `{$config['database']}`;");
}

Expand Down
61 changes: 59 additions & 2 deletions src/Illuminate/Database/Connectors/PostgresConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ protected function getDsn(array $config)
$dsn .= ";application_name='".str_replace("'", "\'", $application_name)."'";
}

return $this->addSslOptions($dsn, $config);
$dsn = $this->addSslOptions($dsn, $config);

return $this->addPostgresOptions($dsn, $config);
}

/**
Expand All @@ -162,7 +164,62 @@ protected function getDsn(array $config)
*/
protected function addSslOptions($dsn, array $config)
{
foreach (['sslmode', 'sslcert', 'sslkey', 'sslrootcert'] as $option) {
foreach ([
'sslmode',
'sslcert',
'sslkey',
'sslrootcert',
'requiressl',
'sslnegotiation',
'sslcompression',
'sslpassword',
'sslcertmode',
'sslcrl',
'sslcrldir',
'sslsni',
] as $option) {
if (isset($config[$option])) {
$dsn .= ";{$option}={$config[$option]}";
}
}

return $dsn;
}

/**
* Add Postgres specific options to the DSN.
*
* @param string $dsn
* @param array $config
* @return string
*/
protected function addPostgresOptions($dsn, array $config)
{
foreach ([
'channel_binding',
'connect_timeout',
'fallback_application_name',
'gssdelegation',
'gssencmode',
'gsslib',
'hostaddr',
'keepalives',
'keepalives_count',
'keepalives_idle',
'keepalives_interval',
'krbsrvname',
'load_balance_hosts',
'options',
'passfile',
'replication',
'require_auth',
'requirepeer',
'service',
'ssl_max_protocol_version',
'ssl_min_protocol_version',
'target_session_attrs',
'tcp_user_timeout',
] as $option) {
if (isset($config[$option])) {
$dsn .= ";{$option}={$config[$option]}";
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/DetectsLostConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ protected function causedByLostConnection(Throwable $e)
'Reason: Server is in script upgrade mode. Only administrator can connect at this time.',
'Unknown $curl_error_code: 77',
'SSL: Handshake timed out',
'SQLSTATE[08006] [7] SSL error: sslv3 alert unexpected message',
'SQLSTATE[08006] [7] unrecognized SSL error code:',
'SSL error: sslv3 alert unexpected message',
'unrecognized SSL error code:',
'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it',
'SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',
'SQLSTATE[HY000] [2002] Network is unreachable',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ public function pluck($column, $key = null)
// If the model has a mutator for the requested column, we will spin through
// the results and mutate the values so that the mutated version of these
// columns are returned as you would expect from these Eloquent models.
if (! $this->model->hasGetMutator($column) &&
if (! $this->model->hasAnyGetMutator($column) &&
! $this->model->hasCast($column) &&
! in_array($column, $this->model->getDates())) {
return $results;
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,17 @@ public function hasAttributeGetMutator($key)
return static::$getAttributeMutatorCache[get_class($this)][$key] = is_callable($this->{Str::camel($key)}()->get);
}

/**
* Determine if any get mutator exists for an attribute.
*
* @param string $key
* @return bool
*/
public function hasAnyGetMutator($key)
{
return $this->hasGetMutator($key) || $this->hasAttributeGetMutator($key);
}

/**
* Get the value of an attribute using its mutator.
*
Expand Down
18 changes: 12 additions & 6 deletions src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ trait HasRelationships
/**
* Get the dynamic relation resolver if defined or inherited, or return null.
*
* @param string $class
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param class-string<TRelatedModel> $class
* @param string $key
* @return mixed
* @return Closure|null
*/
public function relationResolver($class, $key)
{
Expand Down Expand Up @@ -851,8 +853,10 @@ public function getMorphClass()
/**
* Create a new model instance for a related model.
*
* @param string $class
* @return mixed
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param class-string<TRelatedModel> $class
* @return TRelatedModel
*/
protected function newRelatedInstance($class)
{
Expand All @@ -866,8 +870,10 @@ protected function newRelatedInstance($class)
/**
* Create a new model instance for a related "through" model.
*
* @param string $class
* @return mixed
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
*
* @param class-string<TRelatedModel> $class
* @return TRelatedModel
*/
protected function newRelatedThroughInstance($class)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function initializeHasUniqueStringIds()
*/
public function uniqueIds()
{
return [$this->getKeyName()];
return $this->usesUniqueIds() ? [$this->getKeyName()] : parent::uniqueIds();
}

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getKeyType()
return 'string';
}

return $this->keyType;
return parent::getKeyType();
}

/**
Expand All @@ -89,7 +89,7 @@ public function getIncrementing()
return false;
}

return $this->incrementing;
return parent::getIncrementing();
}

/**
Expand Down
Loading

0 comments on commit ba17f0d

Please sign in to comment.