framework
framework copied to clipboard
EncryptionServiceprovider->key(array $config): APP_KEY sometimes null
Laravel Version
11.19.0
PHP Version
8.3.10
Database Driver & Version
No response
Description
(hint: Don't move it to discussion area, it is a BUG !!!!!!!!!!!!!!)
I use Laravel 11 as the backend for the middleware. Frontend is a SPA VUE application. For authentication I use Laravel Sanctum. Problem description: it happens sometimes, during the app runs, that the "app_key" is not defined That's wrong, otherwise it would never work. However, I noticed that in the class "EncryptionServiceProvider" the method "key" with "$config" as a parameter, where the "key" member is really "null". The interesting thing is that all other .env (APP_) entries are there, only the "key" entry is null !!!! What's going on - unfortunately this makes the application completely unstable and unusable
protected function key(array $config) { return tap($config['key'], function ($key) { if (empty($key)) { throw new MissingAppKeyException; } }); }
**here the code where th error occurs: file: \vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php
` protected function registerEncrypter() { $this->app->singleton('encrypter', function ($app) { $config = $app->make('config')->get('app');
return (new Encrypter($this->parseKey($config), $config['cipher']))
->previousKeys(array_map(
fn ($key) => $this->parseKey(['key' => $key]),
$config['previous_keys'] ?? []
));
});
}`** after this command $config = $app->make('config')->get('app'); the $config['key'] is null or empty
Important Hint: $config['key'] is not always null, and it is the only only member of config that is destroyed !!!!!!!!!!!!!!!!!
laravel runs on windows 10 with latest XAMPP
Steps To Reproduce
sorry, if i could reproduce the error, then can i fix it