Fix getting uninitialized default config value

- catch SQL errors in LoadConfig
- incremented DB Version to 14
This commit is contained in:
Andre Lorbach 2023-02-07 10:46:36 +01:00
parent 059334ca85
commit 18c40e1af5
3 changed files with 29 additions and 22 deletions

View File

@ -1908,7 +1908,7 @@ function GetConfigSetting($szSettingName, $szDefaultValue = "", $DesiredConfigLe
if ( isset($CFG[$szSettingName]) )
return $CFG[$szSettingName];
else
return $szDefaultValue;
return (isset($szDefaultValue) ? $szDefaultValue : "");
}
/*

View File

@ -949,30 +949,37 @@ function LoadChartsFromDatabase()
// ---
// Get Searches from DB now!
$result = DB_Query($sqlquery);
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows ) && count($myrows) > 0 )
{
// Overwrite the existing graphics matrix but only the records of
// the database, those of the configuration file we keep.
$not_remove = array();
foreach($CFG['Charts'] as $chartid => $myChart)
try {
$result = DB_Query($sqlquery);
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows ) && count($myrows) > 0 )
{
if (! is_numeric($chartid) ) {
$not_remove[$chartid] = $myChart;
// Overwrite the existing graphics matrix but only the records of
// the database, those of the configuration file we keep.
$not_remove = array();
foreach($CFG['Charts'] as $chartid => $myChart)
{
if (! is_numeric($chartid) ) {
$not_remove[$chartid] = $myChart;
}
}
$CFG['Charts'] = $not_remove;
// Loop through all data rows
foreach ($myrows as &$myChart )
{
// Append to Chart Array
$CFG['Charts'][ $myChart['ID'] ] = $myChart;
}
// Copy to content array!
$content['Charts'] = $CFG['Charts'];
}
$CFG['Charts'] = $not_remove;
// Loop through all data rows
foreach ($myrows as &$myChart )
{
// Append to Chart Array
$CFG['Charts'][ $myChart['ID'] ] = $myChart;
}
} catch (mysqli_sql_exception $e) {
// DEBUG ERROR
OutputDebugMessage("LoadChartsFromDatabase: DB Query failed with Code " . $e->getCode() . ": " . $e->getMessage(), DEBUG_ERROR);
// Copy to content array!
$content['Charts'] = $CFG['Charts'];
$content['Charts'] = array();
}
}

View File

@ -49,7 +49,7 @@ $errdesc = "";
$errno = 0;
// --- Current Database Version, this is important for automated database Updates!
$content['database_internalversion'] = "13"; // Whenever incremented, a database upgrade is needed
$content['database_internalversion'] = "14"; // Whenever incremented, a database upgrade is needed
$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
// ---