CC-5810 : Installation can have race conditions with the cache
Preferences.php is used to set values since it will save the value to cache there as well. defaultdata.sql is used where possible.
This commit is contained in:
parent
abe3b79fed
commit
578f758274
5 changed files with 32 additions and 51 deletions
|
@ -642,6 +642,11 @@ class Application_Model_Preference
|
|||
return self::getValue("logoImage");
|
||||
}
|
||||
|
||||
public static function SetUniqueId($id)
|
||||
{
|
||||
self::setValue("uniqueId", $id);
|
||||
}
|
||||
|
||||
public static function GetUniqueId()
|
||||
{
|
||||
return self::getValue("uniqueId");
|
||||
|
@ -897,6 +902,11 @@ class Application_Model_Preference
|
|||
return self::getValue("enable_stream_conf");
|
||||
}
|
||||
|
||||
public static function SetAirtimeVersion($version)
|
||||
{
|
||||
self::setValue("system_version", $version);
|
||||
}
|
||||
|
||||
public static function GetAirtimeVersion()
|
||||
{
|
||||
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')) {
|
||||
|
|
|
@ -346,3 +346,12 @@ INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski
|
|||
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('zh_CN', '简体中文');
|
||||
|
||||
-- end of added in 2.3
|
||||
|
||||
-- added in 2.5.2
|
||||
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'UTC');
|
||||
INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', 'UTC');
|
||||
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0');
|
||||
|
||||
--end added in 2.5.2
|
||||
|
|
|
@ -308,61 +308,14 @@ class AirtimeInstall
|
|||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$con->exec($sql);
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$p_version')";
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Application_Model_Preference::SetAirtimeVersion($p_version);
|
||||
}
|
||||
|
||||
public static function SetUniqueId()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$uniqueId = md5(uniqid("", true));
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
Application_Model_Preference::SetUniqueId($uniqueId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
// we need to run php as commandline because we want to get the timezone in cli php.ini file
|
||||
//$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'");
|
||||
$defaultTimezone = exec("cat /etc/timezone");
|
||||
$defaultTimezone = trim($defaultTimezone);
|
||||
if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){
|
||||
$defaultTimezone = "UTC";
|
||||
}
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', '$defaultTimezone')";
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function SetImportTimestamp()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
|
||||
$result = $con->exec($sql);
|
||||
if ($result < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function GetAirtimeVersion()
|
||||
{
|
||||
|
|
|
@ -10,10 +10,19 @@ require_once(__DIR__.'/AirtimeInstall.php');
|
|||
require_once(__DIR__.'/airtime-constants.php');
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
|
||||
//Propel classes.
|
||||
set_include_path(AirtimeInstall::GetAirtimeSrcDir().'/application/models' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
||||
|
||||
//use this class to set new values in the cache as well.
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/common/Database.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/models/Preference.php');
|
||||
|
||||
echo PHP_EOL."* Database Installation".PHP_EOL;
|
||||
|
||||
AirtimeInstall::CreateDatabaseUser();
|
||||
|
@ -56,10 +65,8 @@ AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
|||
|
||||
|
||||
if (AirtimeInstall::$databaseTablesCreated) {
|
||||
AirtimeInstall::SetDefaultTimezone();
|
||||
// set up some keys in DB
|
||||
AirtimeInstall::SetUniqueId();
|
||||
AirtimeInstall::SetImportTimestamp();
|
||||
|
||||
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
|
||||
|
||||
|
|
|
@ -4,3 +4,5 @@ INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski
|
|||
|
||||
UPDATE cc_locale SET locale_lang='Deutsch (Österreich)' WHERE locale_code='de_AT';
|
||||
UPDATE cc_locale SET locale_lang='Português Brasileiro' WHERE locale_code='pt_BR';
|
||||
|
||||
-- NOTE BECAUSE OF CACHING NOW ANY UPGRADES TO cc_pref MUST NOT BE DONE HERE.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue