From e6035971015f21d0c2d811f1ea87197049be39f1 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 17 Feb 2015 12:13:37 -0500 Subject: [PATCH] Cleanup and comments --- airtime_mvc/application/Bootstrap.php | 8 +++++--- .../application/common/ProvisioningHelper.php | 12 +++--------- .../controllers/ProvisioningController.php | 7 +++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index fb6ec0ddc..9fb3dd5c0 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -34,9 +34,11 @@ require_once __DIR__.'/modules/rest/controllers/MediaController.php'; require_once (APPLICATION_PATH."/logging/Logging.php"); Logging::setLogPath('/var/log/airtime/zendphp.log'); -if (strpos("/provisioning/create-database", $_SERVER["REDIRECT_URL"]) !== false) { - (new ProvisioningHelper($CC_CONFIG["apiKey"][0]))->createDatabaseAction(); - die; +// We need to manually route because we can't load Zend without the database being initialized first. +if (strpos("/provisioning/create", $_SERVER["REDIRECT_URL"]) !== false) { + $provisioningHelper = new ProvisioningHelper($CC_CONFIG["apiKey"][0]); + $provisioningHelper->createAction(); + die(); } Config::setAirtimeVersion(); diff --git a/airtime_mvc/application/common/ProvisioningHelper.php b/airtime_mvc/application/common/ProvisioningHelper.php index 0537f5f60..95c180e61 100644 --- a/airtime_mvc/application/common/ProvisioningHelper.php +++ b/airtime_mvc/application/common/ProvisioningHelper.php @@ -19,18 +19,12 @@ class ProvisioningHelper { } /** - * Endpoint for setting up and installing the Airtime database + * Endpoint for setting up and installing the Airtime database. This all has to be done without Zend + * which is why the code looks so old school (eg. http_response_code). */ - public function createDatabaseAction() { - Logging::info("Create Database action received"); + public function createAction() { $this->getParams(); - Logging::info("Parameters: " - . "\nUser: " . $this->dbuser - . "\nPass: " . $this->dbpass - . "\nName: " . $this->dbname - . "\nHost: " . $this->dbhost - . "\nOwner: " . $this->dbowner); $apikey = $_SERVER['PHP_AUTH_USER']; if (!isset($apikey) || $apikey != $this->apikey) { diff --git a/airtime_mvc/application/controllers/ProvisioningController.php b/airtime_mvc/application/controllers/ProvisioningController.php index 6c2ea2a5d..fc0c28cbb 100644 --- a/airtime_mvc/application/controllers/ProvisioningController.php +++ b/airtime_mvc/application/controllers/ProvisioningController.php @@ -11,6 +11,13 @@ class ProvisioningController extends Zend_Controller_Action { } + /** + * + * The "create action" is in ProvisioningHelper because it needs to have no dependency on Zend, + * since when we bootstrap Zend, we already need the database set up and working (Bootstrap.php is a mess). + * + */ + /** * Delete the Airtime Pro station's files from Amazon S3 */