-catch all exceptions in Preference model and make header 503
This commit is contained in:
parent
5204da4502
commit
1f214747b2
1 changed files with 102 additions and 93 deletions
|
@ -4,7 +4,7 @@ class Application_Model_Preference
|
|||
{
|
||||
|
||||
public static function SetValue($key, $value, $isUserValue = false){
|
||||
global $CC_CONFIG;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//called from a daemon process
|
||||
|
@ -61,17 +61,19 @@ class Application_Model_Preference
|
|||
." VALUES ($id, '$key', $value)";
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
$con->exec($sql);
|
||||
|
||||
} catch (Exception $e){
|
||||
Logging::log("Could not connect to database.");
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
Logging::log("Could not connect to database.");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function GetValue($key, $isUserValue = false){
|
||||
global $CC_CONFIG;
|
||||
try {
|
||||
$con = Propel::getConnection();
|
||||
|
||||
//Check if key already exists
|
||||
|
@ -100,6 +102,11 @@ class Application_Model_Preference
|
|||
$result = $con->query($sql)->fetchColumn(0);
|
||||
return ($result !== false) ? $result : "";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
Logging::log("Could not connect to database.");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetHeadTitle(){
|
||||
|
@ -567,11 +574,13 @@ class Application_Model_Preference
|
|||
|
||||
public static function GetAirtimeVersion(){
|
||||
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')){
|
||||
return self::GetValue("system_version")."+".exec("git rev-parse --short HEAD");
|
||||
} else {
|
||||
return self::GetValue("system_version");
|
||||
$version = exec("git rev-parse --short HEAD 2>/dev/null", $out, $return_code);
|
||||
if ($return_code == 0){
|
||||
return self::GetValue("system_version")."+".$version;
|
||||
}
|
||||
}
|
||||
return self::GetValue("system_version");
|
||||
}
|
||||
|
||||
public static function GetLatestVersion(){
|
||||
$latest = self::GetValue("latest_version");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue