Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Do not set PHP timezone when bootstrapping configuration #428

Merged
merged 1 commit into from
Jan 26, 2025
Merged
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 config-stubs/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
|
*/

'timezone' => get_option('timezone_string') ?: env('APP_TIMEZONE', 'UTC'),
'timezone' => env('APP_TIMEZONE', 'UTC'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
|
*/

'timezone' => get_option('timezone_string') ?: env('APP_TIMEZONE', 'UTC'),
'timezone' => env('APP_TIMEZONE', 'UTC'),

/*
|--------------------------------------------------------------------------
Expand Down
43 changes: 43 additions & 0 deletions src/Roots/Acorn/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Roots\Acorn\Bootstrap;

use Illuminate\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\LoadConfiguration as FoundationLoadConfiguration;

class LoadConfiguration extends FoundationLoadConfiguration
{
/**
* Bootstrap the given application.
*
* @return void
*/
public function bootstrap(Application $app)
{
$items = [];

// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;

$app->instance('config_loaded_from_cache', $loadedFromCache = true);
}

// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
$app->instance('config', $config = new Repository($items));

if (! isset($loadedFromCache)) {
$this->loadConfigurationFiles($app, $config);
}

// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
$app->detectEnvironment(fn () => $config->get('app.env', 'production'));
}
}
2 changes: 1 addition & 1 deletion src/Roots/Acorn/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Kernel extends FoundationConsoleKernel
*/
protected $bootstrappers = [
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
\Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
\Roots\Acorn\Bootstrap\LoadConfiguration::class,
\Roots\Acorn\Bootstrap\HandleExceptions::class,
\Roots\Acorn\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Roots/Acorn/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Kernel extends HttpKernel
*/
protected $bootstrappers = [
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
\Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
\Roots\Acorn\Bootstrap\LoadConfiguration::class,
\Roots\Acorn\Bootstrap\HandleExceptions::class,
\Roots\Acorn\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
Expand Down
Loading