diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php
index 94e28e620..96bd14909 100644
--- a/airtime_mvc/application/Bootstrap.php
+++ b/airtime_mvc/application/Bootstrap.php
@@ -81,10 +81,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
}
protected function _initUpgrade() {
- if (AIRTIME_CODE_VERSION > Application_Model_Preference::GetAirtimeVersion()) {
- $upgradeManager = new UpgradeManager();
- $upgradeManager->runUpgrades(array(new AirtimeUpgrader252()), (__DIR__ . "/controllers"));
- }
+ UpgradeManager::checkIfUpgradeIsNeeded(); //This will do the upgrade too if it's needed...
}
protected function _initHeadLink()
diff --git a/airtime_mvc/application/controllers/ErrorController.php b/airtime_mvc/application/controllers/ErrorController.php
index 70829db63..2d54269a8 100644
--- a/airtime_mvc/application/controllers/ErrorController.php
+++ b/airtime_mvc/application/controllers/ErrorController.php
@@ -24,9 +24,12 @@ class ErrorController extends Zend_Controller_Action
}
// Log exception, if logger available
+ /* No idea why this doesn't work or why it was implemented like this. Disabling it -- Albert
if (($log = $this->getLog())) {
$log->crit($this->view->message, $errors->exception);
- }
+ }*/
+ //Logging that actually works: -- Albert
+ Logging::error($this->view->message . ": " . $errors->exception);
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php
index 7ff511dee..b52630da4 100644
--- a/airtime_mvc/application/controllers/UpgradeController.php
+++ b/airtime_mvc/application/controllers/UpgradeController.php
@@ -13,25 +13,19 @@ class UpgradeController extends Zend_Controller_Action
return;
}
- $upgraders = array();
- array_push($upgraders, new AirtimeUpgrader252());
- /* These upgrades do not apply to open source Airtime yet.
- array_push($upgraders, new AirtimeUpgrader253());
- array_push($upgraders, new AirtimeUpgrader254());
- */
$didWePerformAnUpgrade = false;
try {
$upgradeManager = new UpgradeManager();
- $didWePerformAnUpgrade = $upgradeManager->runUpgrades($upgraders, __DIR__);
+ $didWePerformAnUpgrade = $upgradeManager->doUpgrade();
if (!$didWePerformAnUpgrade) {
$this->getResponse()
->setHttpResponseCode(200)
- ->appendBody("No upgrade was performed. The current Airtime version is " . AirtimeUpgrader::getCurrentVersion() . ".
");
+ ->appendBody("No upgrade was performed. The current schema version is " . Application_Model_Preference::GetSchemaVersion() . ".
");
} else {
$this->getResponse()
->setHttpResponseCode(200)
- ->appendBody("Upgrade to Airtime " . $upgrader->getNewVersion() . " OK
");
+ ->appendBody("Upgrade to Airtime schema version " . Application_Model_Preference::GetSchemaVersion() . " OK
");
}
}
catch (Exception $e)
diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.2/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.2/upgrade.sql
index cb0c520b7..2f805382d 100644
--- a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.2/upgrade.sql
+++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.2/upgrade.sql
@@ -1,5 +1,6 @@
+-- Replacing system_version with schema_version
DELETE FROM cc_pref WHERE keystr = 'system_version';
-INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.5.2');
+INSERT INTO cc_pref (keystr, valstr) VALUES ('schema_version', '2.5.2');
ALTER TABLE cc_show ADD COLUMN image_path varchar(255) DEFAULT '';
ALTER TABLE cc_show_instances ADD COLUMN description varchar(255) DEFAULT '';
diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php
index e568e0159..6e65b0c4c 100644
--- a/airtime_mvc/application/models/Preference.php
+++ b/airtime_mvc/application/models/Preference.php
@@ -862,10 +862,22 @@ class Application_Model_Preference
return self::getValue("enable_stream_conf");
}
-
- public static function SetAirtimeVersion($version)
+
+ public static function GetSchemaVersion()
{
- self::setValue("system_version", $version);
+ $schemaVersion = self::getValue("schema_version");
+
+ //Pre-2.5.2 releases all used this ambiguous "system_version" key to represent both the code and schema versions...
+ if (empty($schemaVersion)) {
+ $schemaVersion = self::getValue("system_version");
+ }
+
+ return $schemaVersion;
+ }
+
+ public static function SetSchemaVersion($version)
+ {
+ self::setValue("schema_version", $version);
}
public static function GetAirtimeVersion()
diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php
index b4bec0fec..892646e4a 100644
--- a/airtime_mvc/application/models/Show.php
+++ b/airtime_mvc/application/models/Show.php
@@ -1232,6 +1232,7 @@ SELECT si.starts AS start_timestamp,
si.id AS instance_id,
si.record,
s.url,
+ s.image_path,
starts,
ends
FROM cc_show_instances si
diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php
index fe083d1ae..9ee2be523 100644
--- a/airtime_mvc/application/upgrade/Upgrades.php
+++ b/airtime_mvc/application/upgrade/Upgrades.php
@@ -1,6 +1,37 @@
runUpgrades(array(new AirtimeUpgrader252()), (__DIR__ . "/controllers"));
+ }
/**
* Run a given set of upgrades
@@ -10,7 +41,7 @@ class UpgradeManager {
* @return boolean whether or not an upgrade was performed
*/
public function runUpgrades($upgraders, $dir) {
- $upgradePerformed;
+ $upgradePerformed = false;
for($i = 0; $i < count($upgraders); $i++) {
$upgrader = $upgraders[$i];
@@ -29,20 +60,28 @@ class UpgradeManager {
abstract class AirtimeUpgrader
{
- /** Versions that this upgrader class can upgrade from (an array of version strings). */
- abstract protected function getSupportedVersions();
- /** The version that this upgrader class will upgrade to. (returns a version string) */
+ /** Schema versions that this upgrader class can upgrade from (an array of version strings). */
+ abstract protected function getSupportedSchemaVersions();
+ /** The schema version that this upgrader class will upgrade to. (returns a version string) */
abstract public function getNewVersion();
- public static function getCurrentVersion()
+ public static function getCurrentSchemaVersion()
{
CcPrefPeer::clearInstancePool(); //Ensure we don't get a cached Propel object (cached DB results)
//because we're updating this version number within this HTTP request as well.
+
+ //Old versions use system_version
$pref = CcPrefQuery::create()
->filterByKeystr('system_version')
->findOne();
- $airtime_version = $pref->getValStr();
- return $airtime_version;
+ if (empty($pref)) {
+ //New versions use schema_version
+ $pref = CcPrefQuery::create()
+ ->filterByKeystr('schema_version')
+ ->findOne();
+ }
+ $schema_version = $pref->getValStr();
+ return $schema_version;
}
/**
@@ -51,7 +90,7 @@ abstract class AirtimeUpgrader
*/
public function checkIfUpgradeSupported()
{
- if (!in_array(AirtimeUpgrader::getCurrentVersion(), $this->getSupportedVersions())) {
+ if (!in_array(AirtimeUpgrader::getCurrentSchemaVersion(), $this->getSupportedSchemaVersions())) {
return false;
}
return true;
@@ -82,7 +121,7 @@ abstract class AirtimeUpgrader
/** This upgrade adds schema changes to accommodate show artwork and show instance descriptions */
class AirtimeUpgrader252 extends AirtimeUpgrader {
- protected function getSupportedVersions() {
+ protected function getSupportedSchemaVersions() {
return array (
'2.5.1'
);
@@ -114,7 +153,7 @@ class AirtimeUpgrader252 extends AirtimeUpgrader {
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
- Application_Model_Preference::SetAirtimeVersion($newVersion);
+ Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@@ -129,7 +168,7 @@ class AirtimeUpgrader252 extends AirtimeUpgrader {
class AirtimeUpgrader253 extends AirtimeUpgrader
{
- protected function getSupportedVersions()
+ protected function getSupportedSchemaVersions()
{
return array('2.5.2');
}
@@ -181,7 +220,7 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_".$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
- Application_Model_Preference::SetAirtimeVersion($this->getNewVersion());
+ Application_Model_Preference::SetSchemaVersion($this->getNewVersion());
//clear out the cache
Cache::clear();
@@ -196,7 +235,7 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
class AirtimeUpgrader254 extends AirtimeUpgrader
{
- protected function getSupportedVersions()
+ protected function getSupportedSchemaVersions()
{
return array('2.5.3');
}
@@ -266,7 +305,7 @@ class AirtimeUpgrader254 extends AirtimeUpgrader
}
//$con->commit();
- Application_Model_Preference::SetAirtimeVersion($newVersion);
+ Application_Model_Preference::SetSchemaVersion($newVersion);
Cache::clear();
$this->toggleMaintenanceScreen(false);
@@ -292,7 +331,7 @@ class AirtimeUpgrader254 extends AirtimeUpgrader
*
*/
class AirtimeUpgrader256 extends AirtimeUpgrader {
- protected function getSupportedVersions() {
+ protected function getSupportedSchemaVersions() {
return array (
'2.5.4', '2.5.5'
);