mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW: More helpful error when .env is missing.
If your database configuration isn’t found, it’s quite likely that this is because you have a stray _ss_environment.php file that you haven’t converted to a .env file. This patch detects this situation and provides a more helpful error.
This commit is contained in:
parent
f63b741e46
commit
3952769ea3
20
main.php
20
main.php
@ -184,6 +184,26 @@ global $databaseConfig;
|
|||||||
|
|
||||||
// Redirect to the installer if no database is selected
|
// Redirect to the installer if no database is selected
|
||||||
if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
|
if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
|
||||||
|
|
||||||
|
// Is there an _ss_environment.php file?
|
||||||
|
if(file_exists(BASE_PATH . '/_ss_environment.php') || file_exists(dirname(BASE_PATH) . '/_ss_environment.php')) {
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'] . " 500 Server Error");
|
||||||
|
$dv = new SilverStripe\Dev\DebugView();
|
||||||
|
echo $dv->renderHeader();
|
||||||
|
echo $dv->renderInfo(
|
||||||
|
"Configuraton Error",
|
||||||
|
Director::absoluteBaseURL()
|
||||||
|
);
|
||||||
|
echo $dv->renderParagraph(
|
||||||
|
'You need to replace your _ss_environment.php file with a .env file, or with environment variables.<br><br>'
|
||||||
|
. 'See the <a href="https://docs.silverstripe.org/en/4/getting_started/environment_management/">'
|
||||||
|
. 'Environment Management</a> docs for more information.'
|
||||||
|
);
|
||||||
|
echo $dv->renderFooter();
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
if(!file_exists(BASE_PATH . '/install.php')) {
|
if(!file_exists(BASE_PATH . '/install.php')) {
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . " 500 Server Error");
|
header($_SERVER['SERVER_PROTOCOL'] . " 500 Server Error");
|
||||||
die('SilverStripe Framework requires a $databaseConfig defined.');
|
die('SilverStripe Framework requires a $databaseConfig defined.');
|
||||||
|
Loading…
Reference in New Issue
Block a user