0012242: don't throw Fatal Errors when trying to get/setconfig via CLI
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 30 Sep 2016 10:22:43 +0000 (12:22 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 30 Sep 2016 15:31:10 +0000 (17:31 +0200)
https://forge.tine20.org/view.php?id=12242

Change-Id: Ic8f2e13d38f3dcfeec83878b5859ba5a5ca5b36d
Reviewed-on: http://gerrit.tine20.com/customers/3636
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Setup/Frontend/Cli.php

index 223c19d..6509a51 100644 (file)
@@ -528,6 +528,10 @@ class Setup_Frontend_Cli
         $configKey = (string)$options['configkey'];
         $configValue = self::parseConfigValue($options['configvalue']);
         $applicationName = (isset($options['app'])) ? $options['app'] : 'Tinebase';
+
+        if (! Tinebase_Application::getInstance()->isInstalled('Tinebase') || ! Tinebase_Application::getInstance()->isInstalled($applicationName)) {
+            $errors[] = $applicationName . ' is not installed';
+        }
         
         if (empty($errors)) {
            Setup_Controller::getInstance()->setConfigOption($configKey, $configValue, $applicationName);
@@ -548,13 +552,21 @@ class Setup_Frontend_Cli
     {
         $options = $this->_parseRemainingArgs($_opts->getRemainingArgs());
         $applicationName = (isset($options['app'])) ? $options['app'] : 'Tinebase';
-        $config = Tinebase_Config_Abstract::factory($applicationName);
-        
+
         $errors = array();
+        if (! Tinebase_Application::getInstance()->isInstalled('Tinebase') || ! Tinebase_Application::getInstance()->isInstalled($applicationName)) {
+            $errors[] = $applicationName . ' is not installed';
+            $config = null;
+        } else {
+            $config = Tinebase_Config_Abstract::factory($applicationName);
+        }
+
         if (empty($options['configkey'])) {
             $errors[] = 'Missing argument: configkey';
-            $errors[] = 'Available config settings:';
-            $errors[] = print_r($config::getProperties(), true);
+            if ($config) {
+                $errors[] = 'Available config settings:';
+                $errors[] = print_r($config::getProperties(), true);
+            }
         }
         $configKey = (string)$options['configkey'];