Skip to content

Commit

Permalink
🩹 Do not set PHP timezone when bootstrapping configuration (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Jan 26, 2025
1 parent 411892a commit 6f5fd00
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
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

0 comments on commit 6f5fd00

Please sign in to comment.