Merge branch 'saas-dev' into saas-dev-publishing

Conflicts:
	airtime_mvc/application/Bootstrap.php
	airtime_mvc/application/controllers/plugins/Acl_plugin.php
This commit is contained in:
Duncan Sommerville 2015-10-19 16:18:19 -04:00
commit 12f6536e74
32 changed files with 4672 additions and 326 deletions

View file

@ -10,7 +10,7 @@ class Application_Model_Preference
{
//pass in true so the check is made with the autoloader
//we need this check because saas calls this function from outside Zend
if (!class_exists("Zend_Auth", true) || !Zend_Auth::getInstance()->hasIdentity()) {
if (!class_exists("Zend_Session", true) || !Zend_Session::isStarted() || !class_exists("Zend_Auth", true) || !Zend_Auth::getInstance()->hasIdentity()) {
$userId = null;
} else {
$auth = Zend_Auth::getInstance();
@ -150,10 +150,14 @@ class Application_Model_Preference
try {
$userId = self::getUserId();
if ($isUserValue && is_null($userId))
throw new Exception("User id can't be null for a user preference.");
$userId = null;
if ($isUserValue) {
//This is nested in here because so we can still use getValue() when the session hasn't started yet.
$userId = self::getUserId();
if (is_null($userId)) {
throw new Exception("User id can't be null for a user preference.");
}
}
// If the value is already cached, return it
$res = $cache->fetch($key, $isUserValue, $userId);
@ -202,7 +206,7 @@ class Application_Model_Preference
}
catch (Exception $e) {
header('HTTP/1.0 503 Service Unavailable');
Logging::info("Could not connect to database: ".$e->getMessage());
Logging::info("Could not connect to database: ".$e);
exit;
}
}

View file

@ -850,6 +850,9 @@ SQL;
$con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
try {
$con->beginTransaction();
//It is extremely important that we increase the transaction isolation level, so that if two
//requests cause the show schedule to be generated at the same time, one will be rolled back.
$con->exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
//UTC DateTime object
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
@ -862,7 +865,9 @@ SQL;
$con->commit();
} catch (Exception $e) {
$con->rollBack();
throw $e;
//throw $e;
Logging::warn("Did not create show instances due to transaction error. This is usually safe
and caused by two concurrent transactions. " . $e->getMessage());
}
}