CC-5802: Upgrade application.ini file
Used a transaction for upgrades. If upgrading the application.ini file fails, the database upgrades will get rolled back.
This commit is contained in:
parent
42f3bb17e1
commit
6890dcc3bc
|
@ -17,6 +17,9 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
$con->beginTransaction();
|
||||||
|
try {
|
||||||
//Disable Airtime UI
|
//Disable Airtime UI
|
||||||
//create a temporary maintenance notification file
|
//create a temporary maintenance notification file
|
||||||
//when this file is on the server, zend framework redirects all
|
//when this file is on the server, zend framework redirects all
|
||||||
|
@ -67,18 +70,12 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
|
|
||||||
//check that first line is '[production]'
|
//check that first line is '[production]'
|
||||||
if ($beginning != '[production]') {
|
if ($beginning != '[production]') {
|
||||||
$this->getResponse()
|
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Invalid format');
|
||||||
->setHttpResponseCode(400)
|
|
||||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$end = implode("\n", array_slice($lines, 1));
|
$end = implode("\n", array_slice($lines, 1));
|
||||||
|
|
||||||
if (!is_writeable($iniFile)) {
|
if (!is_writeable($iniFile)) {
|
||||||
$this->getResponse()
|
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Permission denied.');
|
||||||
->setHttpResponseCode(400)
|
|
||||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$file = new SplFileObject($iniFile, "w");
|
$file = new SplFileObject($iniFile, "w");
|
||||||
$file->fwrite($beginning."\n".$newLines.$end);
|
$file->fwrite($beginning."\n".$newLines.$end);
|
||||||
|
@ -88,9 +85,19 @@ class UpgradeController extends Zend_Controller_Action
|
||||||
|
|
||||||
//TODO: clear out the cache
|
//TODO: clear out the cache
|
||||||
|
|
||||||
|
$con->commit();
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(200)
|
->setHttpResponseCode(200)
|
||||||
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
||||||
|
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$con->rollback();
|
||||||
|
unlink($maintenanceFile);
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(400)
|
||||||
|
->appendBody($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function verifyAuth()
|
private function verifyAuth()
|
||||||
|
|
Loading…
Reference in New Issue