Skip to content

Commit 6f5fd00

Browse files
authored
🩹 Do not set PHP timezone when bootstrapping configuration (#428)
1 parent 411892a commit 6f5fd00

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

config-stubs/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
|
6666
*/
6767

68-
'timezone' => get_option('timezone_string') ?: env('APP_TIMEZONE', 'UTC'),
68+
'timezone' => env('APP_TIMEZONE', 'UTC'),
6969

7070
/*
7171
|--------------------------------------------------------------------------

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
|
7373
*/
7474

75-
'timezone' => get_option('timezone_string') ?: env('APP_TIMEZONE', 'UTC'),
75+
'timezone' => env('APP_TIMEZONE', 'UTC'),
7676

7777
/*
7878
|--------------------------------------------------------------------------
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Roots\Acorn\Bootstrap;
4+
5+
use Illuminate\Config\Repository;
6+
use Illuminate\Contracts\Foundation\Application;
7+
use Illuminate\Foundation\Bootstrap\LoadConfiguration as FoundationLoadConfiguration;
8+
9+
class LoadConfiguration extends FoundationLoadConfiguration
10+
{
11+
/**
12+
* Bootstrap the given application.
13+
*
14+
* @return void
15+
*/
16+
public function bootstrap(Application $app)
17+
{
18+
$items = [];
19+
20+
// First we will see if we have a cache configuration file. If we do, we'll load
21+
// the configuration items from that file so that it is very quick. Otherwise
22+
// we will need to spin through every configuration file and load them all.
23+
if (file_exists($cached = $app->getCachedConfigPath())) {
24+
$items = require $cached;
25+
26+
$app->instance('config_loaded_from_cache', $loadedFromCache = true);
27+
}
28+
29+
// Next we will spin through all of the configuration files in the configuration
30+
// directory and load each one into the repository. This will make all of the
31+
// options available to the developer for use in various parts of this app.
32+
$app->instance('config', $config = new Repository($items));
33+
34+
if (! isset($loadedFromCache)) {
35+
$this->loadConfigurationFiles($app, $config);
36+
}
37+
38+
// Finally, we will set the application's environment based on the configuration
39+
// values that were loaded. We will pass a callback which will be used to get
40+
// the environment in a web context where an "--env" switch is not present.
41+
$app->detectEnvironment(fn () => $config->get('app.env', 'production'));
42+
}
43+
}

src/Roots/Acorn/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Kernel extends FoundationConsoleKernel
5757
*/
5858
protected $bootstrappers = [
5959
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
60-
\Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
60+
\Roots\Acorn\Bootstrap\LoadConfiguration::class,
6161
\Roots\Acorn\Bootstrap\HandleExceptions::class,
6262
\Roots\Acorn\Bootstrap\RegisterFacades::class,
6363
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,

src/Roots/Acorn/Http/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Kernel extends HttpKernel
1313
*/
1414
protected $bootstrappers = [
1515
\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
16-
\Illuminate\Foundation\Bootstrap\LoadConfiguration::class,
16+
\Roots\Acorn\Bootstrap\LoadConfiguration::class,
1717
\Roots\Acorn\Bootstrap\HandleExceptions::class,
1818
\Roots\Acorn\Bootstrap\RegisterFacades::class,
1919
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,

0 commit comments

Comments
 (0)