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