From 28d2bdbbecfe1af4b2562c58ce29de2a5e8d34ef Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 19 Sep 2014 12:58:31 -0400 Subject: [PATCH] Updated upgrade functions to have a directory parameter, since __DIR__ --- airtime_mvc/application/controllers/UpgradeController.php | 3 ++- airtime_mvc/application/upgrade/Upgrades.php | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index c2a06cd79..dbf36de6c 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -26,7 +26,8 @@ class UpgradeController extends Zend_Controller_Action $upgrader = $upgraders[$i]; if ($upgrader->checkIfUpgradeSupported()) { - $upgrader->upgrade(); //This will throw an exception if the upgrade fails. + // pass __DIR__ to the upgrades, since __DIR__ returns parent dir of file, not executor + $upgrader->upgrade(__DIR__); //This will throw an exception if the upgrade fails. $didWePerformAnUpgrade = true; $this->getResponse() ->setHttpResponseCode(200) diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php index 27fe15bd1..428d9e2b0 100644 --- a/airtime_mvc/application/upgrade/Upgrades.php +++ b/airtime_mvc/application/upgrade/Upgrades.php @@ -64,7 +64,7 @@ class AirtimeUpgrader253 extends AirtimeUpgrader return '2.5.3'; } - public function upgrade() + public function upgrade($dir = __DIR__) { Cache::clear(); assert($this->checkIfUpgradeSupported()); @@ -104,7 +104,6 @@ class AirtimeUpgrader253 extends AirtimeUpgrader $password = $values['database']['dbpass']; $host = $values['database']['host']; $database = $values['database']['dbname']; - $dir = __DIR__; 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\""); @@ -219,7 +218,7 @@ class AirtimeUpgrader255 extends AirtimeUpgrader { return '2.5.5'; } - public function upgrade() { + public function upgrade($dir = __DIR__) { Cache::clear(); assert($this->checkIfUpgradeSupported()); @@ -237,8 +236,7 @@ class AirtimeUpgrader255 extends AirtimeUpgrader { $password = $values['database']['dbpass']; $host = $values['database']['host']; $database = $values['database']['dbname']; - $dir = __DIR__; - + 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\"");