mirror of
https://github.com/grocy/grocy.git
synced 2026-10-16 21:00:04 +02:00
Return HTTP 500 for configuration validation problems (closes #2983)
This commit is contained in:
parent
e83699b346
commit
85dc601b37
1
app.php
1
app.php
|
|
@ -46,6 +46,7 @@ try
|
|||
}
|
||||
catch (\Grocy\Helpers\EInvalidConfig $ex)
|
||||
{
|
||||
http_response_code(500);
|
||||
exit('Invalid setting in config.php: ' . $ex->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ class PrerequisiteChecker
|
|||
{
|
||||
public function checkRequirements()
|
||||
{
|
||||
self::checkForPhpVersion();
|
||||
self::checkForConfigFile();
|
||||
self::checkForConfigDistFile();
|
||||
self::checkForComposer();
|
||||
self::checkForPhpExtensions();
|
||||
self::checkForSqliteVersion();
|
||||
self::CheckPhpVersion();
|
||||
self::CheckConfigFile();
|
||||
self::CheckConfigDistFile();
|
||||
self::CheckComposer();
|
||||
self::CheckPhpExtensions();
|
||||
self::CheckSqliteVersion();
|
||||
}
|
||||
|
||||
private function checkForComposer()
|
||||
private function CheckComposer()
|
||||
{
|
||||
if (!file_exists(__DIR__ . '/../packages/autoload.php'))
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ class PrerequisiteChecker
|
|||
}
|
||||
}
|
||||
|
||||
private function checkForConfigDistFile()
|
||||
private function CheckConfigDistFile()
|
||||
{
|
||||
if (!file_exists(__DIR__ . '/../config-dist.php'))
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ class PrerequisiteChecker
|
|||
}
|
||||
}
|
||||
|
||||
private function checkForConfigFile()
|
||||
private function CheckConfigFile()
|
||||
{
|
||||
if (!file_exists(GROCY_DATAPATH . '/config.php'))
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ class PrerequisiteChecker
|
|||
}
|
||||
}
|
||||
|
||||
private function checkForPhpExtensions()
|
||||
private function CheckPhpExtensions()
|
||||
{
|
||||
$loadedExtensions = get_loaded_extensions();
|
||||
foreach (REQUIRED_PHP_EXTENSIONS as $extension)
|
||||
|
|
@ -63,16 +63,16 @@ class PrerequisiteChecker
|
|||
}
|
||||
}
|
||||
|
||||
private function checkForSqliteVersion()
|
||||
private function CheckSqliteVersion()
|
||||
{
|
||||
$sqliteVersion = self::getSqlVersionAsString();
|
||||
$sqliteVersion = self::GetSqlVersion();
|
||||
if (version_compare($sqliteVersion, REQUIRED_SQLITE_VERSION, '<'))
|
||||
{
|
||||
throw new ERequirementNotMet('SQLite ' . REQUIRED_SQLITE_VERSION . ' is required, however you are running ' . $sqliteVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkForPhpVersion()
|
||||
private function CheckPhpVersion()
|
||||
{
|
||||
$phpVersion = phpversion();
|
||||
if (version_compare($phpVersion, REQUIRED_PHP_VERSION, '<'))
|
||||
|
|
@ -81,7 +81,7 @@ class PrerequisiteChecker
|
|||
}
|
||||
}
|
||||
|
||||
private function getSqlVersionAsString()
|
||||
private function GetSqlVersion(): string
|
||||
{
|
||||
$dbh = new \PDO('sqlite::memory:');
|
||||
return $dbh->query('select sqlite_version()')->fetch()[0];
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ try
|
|||
}
|
||||
catch (Grocy\Helpers\ERequirementNotMet $ex)
|
||||
{
|
||||
http_response_code(500);
|
||||
exit('Unable to run Grocy: ' . $ex->getMessage());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user