From 330d62984b7c0c5ec94028653a3008236bed2a90 Mon Sep 17 00:00:00 2001 From: vrana Date: Thu, 22 Mar 2012 15:44:34 -0700 Subject: [PATCH] Check required classes in setup Test Plan: Run setup with 'differential.attach-task-class' set to: - '' - 'FacebookTasksAttacher' - 'X' Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1999 --- src/infrastructure/env/PhabricatorEnv.php | 35 ++++++++++--------- src/infrastructure/setup/PhabricatorSetup.php | 16 +++++++++ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index 1335606d49..8dd48c779c 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -22,21 +22,6 @@ final class PhabricatorEnv { private static $env; - private static $requiredClasses = array( - 'metamta.mail-adapter' => 'PhabricatorMailImplementationAdapter', - 'metamta.maniphest.reply-handler' => 'PhabricatorMailReplyHandler', - 'metamta.differential.reply-handler' => 'PhabricatorMailReplyHandler', - 'metamta.diffusion.reply-handler' => 'PhabricatorMailReplyHandler', - 'storage.engine-selector' => 'PhabricatorFileStorageEngineSelector', - 'search.engine-selector' => 'PhabricatorSearchEngineSelector', - 'differential.field-selector' => 'DifferentialFieldSelector', - 'maniphest.custom-task-extensions-class' => 'ManiphestTaskExtensions', - 'aphront.default-application-configuration-class' => - 'AphrontApplicationConfiguration', - 'controller.oauth-registration' => 'PhabricatorOAuthRegistrationController', - 'differential.attach-task-class' => 'DifferentialTasksAttacher', - ); - public static function setEnvConfig(array $config) { self::$env = $config; } @@ -48,7 +33,7 @@ final class PhabricatorEnv { public static function newObjectFromConfig($key, $args = array()) { $class = self::getEnvConfig($key); $object = newv($class, $args); - $instanceof = idx(self::$requiredClasses, $key); + $instanceof = idx(self::getRequiredClasses(), $key); if (!($object instanceof $instanceof)) { throw new Exception("Config setting '$key' must be an instance of ". "'$instanceof', is '".get_class($object)."'."); @@ -56,6 +41,24 @@ final class PhabricatorEnv { return $object; } + public static function getRequiredClasses() { + return array( + 'metamta.mail-adapter' => 'PhabricatorMailImplementationAdapter', + 'metamta.maniphest.reply-handler' => 'PhabricatorMailReplyHandler', + 'metamta.differential.reply-handler' => 'PhabricatorMailReplyHandler', + 'metamta.diffusion.reply-handler' => 'PhabricatorMailReplyHandler', + 'storage.engine-selector' => 'PhabricatorFileStorageEngineSelector', + 'search.engine-selector' => 'PhabricatorSearchEngineSelector', + 'differential.field-selector' => 'DifferentialFieldSelector', + 'maniphest.custom-task-extensions-class' => 'ManiphestTaskExtensions', + 'aphront.default-application-configuration-class' => + 'AphrontApplicationConfiguration', + 'controller.oauth-registration' => + 'PhabricatorOAuthRegistrationController', + 'differential.attach-task-class' => 'DifferentialTasksAttacher', + ); + } + public static function envConfigExists($key) { return array_key_exists($key, self::$env); } diff --git a/src/infrastructure/setup/PhabricatorSetup.php b/src/infrastructure/setup/PhabricatorSetup.php index af156acc40..a740cce548 100644 --- a/src/infrastructure/setup/PhabricatorSetup.php +++ b/src/infrastructure/setup/PhabricatorSetup.php @@ -734,6 +734,22 @@ final class PhabricatorSetup { self::write("[OKAY] Mail configuration OKAY\n"); } + self::writeHeader('CONFIG CLASSES'); + foreach (PhabricatorEnv::getRequiredClasses() as $key => $class) { + if (!PhabricatorEnv::getEnvConfig($key)) { + self::writeNote("'$key' is not set."); + } else { + try { + PhabricatorEnv::newObjectFromConfig($key); + } catch (Exception $ex) { + self::writeFailure(); + self::write("Setup failure! ".$ex->getMessage()); + return; + } + } + } + self::write("[OKAY] Config classes OKAY\n"); + self::writeHeader('SUCCESS!'); self::write( "Congratulations! Your setup seems mostly correct, or at least fairly ".