Skip to content

Commit e688fdd

Browse files
📦️ Update Foundation to Laravel v13.22.0
1 parent 59c25be commit e688fdd

42 files changed

Lines changed: 1813 additions & 932 deletions

Some content is hidden

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

src/Illuminate/Foundation/Application.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
4545
*
4646
* @var string
4747
*/
48-
const VERSION = '13.12.0';
48+
const VERSION = '13.22.0';
4949

5050
/**
5151
* The base path for the Laravel installation.
@@ -208,6 +208,13 @@ class Application extends Container implements ApplicationContract, CachesConfig
208208
*/
209209
protected $absoluteCachePathPrefixes = ['/', '\\'];
210210

211+
/**
212+
* The application builder class.
213+
*
214+
* @var class-string<Configuration\ApplicationBuilder>
215+
*/
216+
protected static string $applicationBuilder = Configuration\ApplicationBuilder::class;
217+
211218
/**
212219
* Create a new Illuminate application instance.
213220
*
@@ -238,7 +245,7 @@ public static function configure(?string $basePath = null)
238245
default => static::inferBasePath(),
239246
};
240247

241-
return (new Configuration\ApplicationBuilder(new static($basePath)))
248+
return (new static::$applicationBuilder(new static($basePath)))
242249
->withKernels()
243250
->withEvents()
244251
->withCommands()
@@ -1658,6 +1665,7 @@ public function registerCoreContainerAliases()
16581665
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
16591666
'hash' => [\Illuminate\Hashing\HashManager::class],
16601667
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
1668+
'image' => [\Illuminate\Image\ImageManager::class],
16611669
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
16621670
'mail.manager' => [\Illuminate\Mail\MailManager::class, \Illuminate\Contracts\Mail\Factory::class],
16631671
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation;
4+
5+
use Illuminate\Contracts\Foundation\MaintenanceMode;
6+
7+
class ArrayMaintenanceMode implements MaintenanceMode
8+
{
9+
/**
10+
* Indicates if maintenance mode is currently active.
11+
*
12+
* @var bool
13+
*/
14+
protected $active = false;
15+
16+
/**
17+
* The payload provided when maintenance mode was activated.
18+
*
19+
* @var array
20+
*/
21+
protected $payload = [];
22+
23+
/**
24+
* Take the application down for maintenance.
25+
*
26+
* @param array $payload
27+
* @return void
28+
*/
29+
public function activate(array $payload): void
30+
{
31+
$this->active = true;
32+
$this->payload = $payload;
33+
}
34+
35+
/**
36+
* Take the application out of maintenance.
37+
*
38+
* @return void
39+
*/
40+
public function deactivate(): void
41+
{
42+
$this->active = false;
43+
$this->payload = [];
44+
}
45+
46+
/**
47+
* Determine if the application is currently down for maintenance.
48+
*
49+
* @return bool
50+
*/
51+
public function active(): bool
52+
{
53+
return $this->active;
54+
}
55+
56+
/**
57+
* Get the data array which was provided when the application was placed into maintenance.
58+
*
59+
* @return array
60+
*/
61+
public function data(): array
62+
{
63+
return $this->payload;
64+
}
65+
}

src/Illuminate/Foundation/Bootstrap/HandleExceptions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public function handleDeprecationError($message, $file, $line, $level = E_DEPREC
9292
return;
9393
}
9494

95+
if (! static::$app->bound('config')) {
96+
return;
97+
}
98+
9599
try {
96100
$logger = static::$app->make(LogManager::class);
97101
} catch (Exception) {
@@ -121,6 +125,7 @@ public function handleDeprecationError($message, $file, $line, $level = E_DEPREC
121125
protected function shouldIgnoreDeprecationErrors()
122126
{
123127
return ! class_exists(LogManager::class)
128+
|| is_null(static::$app)
124129
|| ! static::$app->hasBeenBootstrapped()
125130
|| (static::$app->runningUnitTests() && ! Env::get('LOG_DEPRECATIONS_WHILE_TESTING'));
126131
}

src/Illuminate/Foundation/Cloud.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ public static function ensureMigrationsUseUnpooledConnection(Application $app):
132132

133133
/**
134134
* Configure managed queues if applicable.
135+
*
136+
* @throws \JsonException
135137
*/
136138
public static function configureManagedQueues(Application $app): void
137139
{
@@ -184,7 +186,7 @@ public static function configureCloudLogging(Application $app): void
184186
'includeStacktraces' => true,
185187
]);
186188

187-
$app['config']->set('logging.channels.laravel-cloud-socket', [
189+
$channel = [
188190
'driver' => 'monolog',
189191
'level' => $_ENV['LOG_LEVEL'] ?? $_SERVER['LOG_LEVEL'] ?? 'debug',
190192
'handler' => SocketHandler::class,
@@ -196,7 +198,13 @@ public static function configureCloudLogging(Application $app): void
196198
'connectionString' => Cloud::socket(),
197199
'persistent' => true,
198200
],
199-
]);
201+
];
202+
203+
$app['config']->set('logging.channels.laravel-cloud-socket', $channel);
204+
205+
if (! $app['config']->has('logging.channels.cloud')) {
206+
$app['config']->set('logging.channels.cloud', $channel);
207+
}
200208
}
201209

202210
/**
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation\Cloud;
4+
5+
use Illuminate\Contracts\Database\LostConnectionDetector;
6+
use Throwable;
7+
8+
/**
9+
* Treats an unreachable cloud-agent runtime socket as a lost connection so the
10+
* worker exits and the pod restarts — the only way to recover an agent that
11+
* has died in-pod. Every other exception is delegated to parent instance.
12+
*/
13+
class AgentAwareLostConnectionDetector implements LostConnectionDetector
14+
{
15+
/**
16+
* Create a new detector instance.
17+
*/
18+
public function __construct(
19+
protected LostConnectionDetector $detector,
20+
) {
21+
//
22+
}
23+
24+
/**
25+
* Determine if the given exception was caused by a lost connection.
26+
*/
27+
public function causedByLostConnection(Throwable $e): bool
28+
{
29+
return $e instanceof AgentUnreachableException
30+
|| $this->detector->causedByLostConnection($e);
31+
}
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation\Cloud;
4+
5+
use RuntimeException;
6+
7+
class AgentUnreachableException extends RuntimeException
8+
{
9+
//
10+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation\Cloud;
4+
5+
use Aws\Sqs\SqsClient;
6+
use Illuminate\Container\Container;
7+
use Illuminate\Queue\Jobs\Job;
8+
use Illuminate\Queue\Jobs\SqsJob;
9+
10+
class CloudJob extends SqsJob
11+
{
12+
/**
13+
* Create a new job instance.
14+
*
15+
* @param array $job
16+
* @param string $connectionName
17+
* @param string $queue
18+
* @param callable(string, int|null): void $reporter
19+
* @param array $overflowStorage
20+
*/
21+
public function __construct(
22+
Container $container,
23+
SqsClient $sqs,
24+
array $job,
25+
$connectionName,
26+
$queue,
27+
protected $reporter,
28+
array $overflowStorage = [],
29+
) {
30+
parent::__construct($container, $sqs, $job, $connectionName, $queue, $overflowStorage);
31+
}
32+
33+
/**
34+
* Delete the job from the queue.
35+
*
36+
* @return void
37+
*/
38+
public function delete()
39+
{
40+
// Skip SQS deletion so SQS DeleteMessage is left to the poller...
41+
Job::delete();
42+
43+
$this->report('processed');
44+
45+
// Only reached once the agent has accepted the outcome (report() throws otherwise)...
46+
$this->deleteOverflowPayload();
47+
}
48+
49+
/**
50+
* Release the job back into the queue after (n) seconds.
51+
*
52+
* @param int $delay
53+
* @return void
54+
*/
55+
public function release($delay = 0)
56+
{
57+
// Skip SQS deletion so SQS release is left to the poller...
58+
Job::release($delay);
59+
60+
$this->report('released', delay: $delay);
61+
}
62+
63+
/**
64+
* Report the job's outcome to the agent, which owns the SQS operation.
65+
*/
66+
protected function report(string $status, ?int $delay = null): void
67+
{
68+
($this->reporter)($status, $delay);
69+
}
70+
}

src/Illuminate/Foundation/Cloud/Events.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public function emitMany(array $payloads): void
5555

5656
/**
5757
* Write the payload to the socket.
58-
*
59-
* @param list<array<string, mixed>> $payloads
6058
*/
6159
protected function write(string $payload): void
6260
{
@@ -101,6 +99,8 @@ protected function write(string $payload): void
10199
* Format the payload.
102100
*
103101
* @param list<array<string, mixed>> $payloads
102+
*
103+
* @throws \JsonException
104104
*/
105105
protected function format(array $payloads): string
106106
{

src/Illuminate/Foundation/Cloud/FailedJobProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public function all()
103103
*
104104
* @param mixed $id
105105
* @return object|null
106+
*
107+
* @throws \JsonException
106108
*/
107109
public function find($id)
108110
{
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Illuminate\Foundation\Cloud;
4+
5+
use Illuminate\Container\Container;
6+
use Monolog\Formatter\JsonFormatter as BaseFormatter;
7+
use Monolog\LogRecord;
8+
9+
class JsonFormatter extends BaseFormatter
10+
{
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
protected function normalizeRecord(LogRecord $record): array
15+
{
16+
$normalized = parent::normalizeRecord($record);
17+
18+
$app = Container::getInstance();
19+
20+
if ($app->bound('request')) {
21+
$requestId = $app->make('request')->header('Cloud-Request-ID');
22+
23+
if ($requestId !== null) {
24+
$normalized['cloud_request_id'] = $requestId;
25+
}
26+
}
27+
28+
return $normalized;
29+
}
30+
}

0 commit comments

Comments
 (0)