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;
|
||||
}
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
//Disable Airtime UI
|
||||
//create a temporary maintenance notification file
|
||||
//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]'
|
||||
if ($beginning != '[production]') {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
||||
return;
|
||||
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Invalid format');
|
||||
}
|
||||
$end = implode("\n", array_slice($lines, 1));
|
||||
|
||||
if (!is_writeable($iniFile)) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
|
||||
return;
|
||||
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Permission denied.');
|
||||
}
|
||||
$file = new SplFileObject($iniFile, "w");
|
||||
$file->fwrite($beginning."\n".$newLines.$end);
|
||||
|
@ -88,9 +85,19 @@ class UpgradeController extends Zend_Controller_Action
|
|||
|
||||
//TODO: clear out the cache
|
||||
|
||||
$con->commit();
|
||||
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->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()
|
||||
|
|
Loading…
Reference in New Issue