Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/AliasLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AliasLoader
/**
* The singleton instance of the loader.
*
* @var \Illuminate\Foundation\AliasLoader
* @var \Illuminate\Foundation\AliasLoader|null
*/
protected static $instance;

Expand Down
23 changes: 16 additions & 7 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use Symfony\Component\HttpKernel\HttpKernelInterface;

use function Illuminate\Filesystem\join_paths;
use function Illuminate\Support\enum_value;

class Application extends Container implements ApplicationContract, CachesConfiguration, CachesRoutes, HttpKernelInterface
{
Expand All @@ -45,7 +46,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '13.12.0';
const VERSION = '13.39.0';

/**
* The base path for the Laravel installation.
Expand Down Expand Up @@ -190,7 +191,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
/**
* The application namespace.
*
* @var string
* @var string|null
*/
protected $namespace;

Expand All @@ -208,6 +209,13 @@ class Application extends Container implements ApplicationContract, CachesConfig
*/
protected $absoluteCachePathPrefixes = ['/', '\\'];

/**
* The application builder class.
*
* @var class-string<Configuration\ApplicationBuilder>
*/
protected static string $applicationBuilder = Configuration\ApplicationBuilder::class;

/**
* Create a new Illuminate application instance.
*
Expand Down Expand Up @@ -238,7 +246,7 @@ public static function configure(?string $basePath = null)
default => static::inferBasePath(),
};

return (new Configuration\ApplicationBuilder(new static($basePath)))
return (new static::$applicationBuilder(new static($basePath)))
->withKernels()
->withEvents()
->withCommands()
Expand Down Expand Up @@ -317,12 +325,12 @@ protected function registerLaravelCloudServices()

$this['events']->listen(
'bootstrapping: *',
fn ($bootstrapper) => Cloud::bootstrapperBootstrapping($this, Str::after($bootstrapper, 'bootstrapping: '))
fn ($bootstrapper) => CloudBootstrapper::bootstrapping($this, Str::after($bootstrapper, 'bootstrapping: '))
);

$this['events']->listen(
'bootstrapped: *',
fn ($bootstrapper) => Cloud::bootstrapperBootstrapped($this, Str::after($bootstrapper, 'bootstrapped: '))
fn ($bootstrapper) => CloudBootstrapper::bootstrapped($this, Str::after($bootstrapper, 'bootstrapped: '))
);
}

Expand Down Expand Up @@ -743,15 +751,15 @@ public function environmentFilePath()
/**
* Get or check the current application environment.
*
* @param string|array ...$environments
* @param \UnitEnum|string|array ...$environments
* @return string|bool
*/
public function environment(...$environments)
{
if ($environments !== []) {
$patterns = is_array($environments[0]) ? $environments[0] : $environments;

return Str::is($patterns, $this['env']);
return Str::is(array_map(enum_value(...), $patterns), $this['env']);
}

return $this['env'];
Expand Down Expand Up @@ -1658,6 +1666,7 @@ public function registerCoreContainerAliases()
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Hashing\HashManager::class],
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
'image' => [\Illuminate\Image\ImageManager::class],
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
'mail.manager' => [\Illuminate\Mail\MailManager::class, \Illuminate\Contracts\Mail\Factory::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
Expand Down
65 changes: 65 additions & 0 deletions src/Illuminate/Foundation/ArrayMaintenanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Illuminate\Foundation;

use Illuminate\Contracts\Foundation\MaintenanceMode;

class ArrayMaintenanceMode implements MaintenanceMode
{
/**
* Indicates if maintenance mode is currently active.
*
* @var bool
*/
protected $active = false;

/**
* The payload provided when maintenance mode was activated.
*
* @var array
*/
protected $payload = [];

/**
* Take the application down for maintenance.
*
* @param array $payload
* @return void
*/
public function activate(array $payload): void
{
$this->active = true;
$this->payload = $payload;
}

/**
* Take the application out of maintenance.
*
* @return void
*/
public function deactivate(): void
{
$this->active = false;
$this->payload = [];
}

/**
* Determine if the application is currently down for maintenance.
*
* @return bool
*/
public function active(): bool
{
return $this->active;
}

/**
* Get the data array which was provided when the application was placed into maintenance.
*
* @return array
*/
public function data(): array
{
return $this->payload;
}
}
37 changes: 22 additions & 15 deletions src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HandleExceptions
/**
* The application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
* @var \Illuminate\Contracts\Foundation\Application|null
*/
protected static $app;

Expand Down Expand Up @@ -92,25 +92,31 @@ public function handleDeprecationError($message, $file, $line, $level = E_DEPREC
return;
}

try {
$logger = static::$app->make(LogManager::class);
} catch (Exception) {
if (! static::$app->bound('config')) {
return;
}

$this->ensureDeprecationLoggerIsConfigured();
try {
$logger = static::$app->make(LogManager::class);

$options = static::$app['config']->get('logging.deprecations') ?? [];
$this->ensureDeprecationLoggerIsConfigured();

with($logger->channel('deprecations'), function ($log) use ($message, $file, $line, $level, $options) {
if ($options['trace'] ?? false) {
$log->warning((string) new ErrorException($message, 0, $level, $file, $line));
} else {
$log->warning(sprintf('%s in %s on line %s',
$message, $file, $line
));
}
});
$options = static::$app['config']->get('logging.deprecations') ?? [];

with($logger->channel('deprecations'), function ($log) use ($message, $file, $line, $level, $options) {
if ($options['trace'] ?? false) {
$log->warning($message, [
'exception' => new ErrorException($message, 0, $level, $file, $line),
]);
} else {
$log->warning(sprintf('%s in %s on line %s',
$message, $file, $line
));
}
});
} catch (Throwable) {
return;
}
}

/**
Expand All @@ -121,6 +127,7 @@ public function handleDeprecationError($message, $file, $line, $level = E_DEPREC
protected function shouldIgnoreDeprecationErrors()
{
return ! class_exists(LogManager::class)
|| is_null(static::$app)
|| ! static::$app->hasBeenBootstrapped()
|| (static::$app->runningUnitTests() && ! Env::get('LOG_DEPRECATIONS_WHILE_TESTING'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function bootstrap(Application $app)
// we will need to spin through every configuration file and load them all.
$loadedFromCache = false;

if (self::$alwaysUseConfig !== null) {
if (static::$alwaysUseConfig !== null) {
$items = $app->call(self::$alwaysUseConfig);

$loadedFromCache = true;
Expand Down
45 changes: 32 additions & 13 deletions src/Illuminate/Foundation/Bus/PendingDispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
use Illuminate\Foundation\Queue\InteractsWithUniqueJobs;
use Illuminate\Queue\Attributes\DebounceFor;
use Illuminate\Queue\Attributes\ReadsQueueAttributes;
use Illuminate\Queue\Events\UniqueJobSkipped;
use Illuminate\Support\Traits\Conditionable;
use LogicException;
use Throwable;

class PendingDispatch
{
Expand Down Expand Up @@ -215,8 +217,19 @@ protected function shouldDispatch()
return true;
}

return (new UniqueLock(Container::getInstance()->make(Cache::class)))
->acquire($this->job);
$container = Container::getInstance();

$lockAcquired = (new UniqueLock($container->make(Cache::class)))->acquire($this->job);

if ($lockAcquired) {
return true;
}

if ($container->bound('events')) {
$container->make('events')->dispatch(new UniqueJobSkipped($this->job));
}

return false;
}

/**
Expand Down Expand Up @@ -282,22 +295,28 @@ public function __call($method, $parameters)
*/
public function __destruct()
{
$this->addUniqueJobInformationToContext($this->job);

if (! $this->shouldDispatch()) {
$this->removeUniqueJobInformationFromContext($this->job);

return;
}

$this->acquireDebounceLock();
$this->addUniqueJobInformationToContext($this->job);

if ($this->afterResponse) {
app(Dispatcher::class)->dispatchAfterResponse($this->job);
} else {
app(Dispatcher::class)->dispatch($this->job);
try {
$this->acquireDebounceLock();

if ($this->afterResponse) {
app(Dispatcher::class)->dispatchAfterResponse($this->job);
} else {
app(Dispatcher::class)->dispatch($this->job);
}
} catch (Throwable $e) {
if ($this->job instanceof ShouldBeUnique) {
(new UniqueLock(Container::getInstance()->make(Cache::class)))->release($this->job);
}

throw $e;
} finally {
$this->removeUniqueJobInformationFromContext($this->job);
}

$this->removeUniqueJobInformationFromContext($this->job);
}
}
Loading