1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-03 11:21:01 +01:00

Convert cluster/projects config options to newer modular structure

Summary: Ref T12845. Converts the cluster and project config options to the new stuff; this is mostly just shifting boilerplate around.

Test Plan: Edited, deleted, and mangled these options from the web UI and CLI.

Reviewers: chad, amckinley

Reviewed By: amckinley

Maniphest Tasks: T12845

Differential Revision: https://secure.phabricator.com/D18166
This commit is contained in:
epriestley 2017-06-27 09:50:57 -07:00
parent 6984d239b0
commit b46e2bb4cc
13 changed files with 77 additions and 80 deletions

View file

@ -2331,13 +2331,13 @@ phutil_register_library_map(array(
'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php', 'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php',
'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php', 'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php',
'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php', 'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php',
'PhabricatorClusterDatabasesConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php', 'PhabricatorClusterDatabasesConfigType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php',
'PhabricatorClusterException' => 'infrastructure/cluster/exception/PhabricatorClusterException.php', 'PhabricatorClusterException' => 'infrastructure/cluster/exception/PhabricatorClusterException.php',
'PhabricatorClusterExceptionHandler' => 'infrastructure/cluster/exception/PhabricatorClusterExceptionHandler.php', 'PhabricatorClusterExceptionHandler' => 'infrastructure/cluster/exception/PhabricatorClusterExceptionHandler.php',
'PhabricatorClusterImpossibleWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImpossibleWriteException.php', 'PhabricatorClusterImpossibleWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImpossibleWriteException.php',
'PhabricatorClusterImproperWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImproperWriteException.php', 'PhabricatorClusterImproperWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImproperWriteException.php',
'PhabricatorClusterNoHostForRoleException' => 'infrastructure/cluster/exception/PhabricatorClusterNoHostForRoleException.php', 'PhabricatorClusterNoHostForRoleException' => 'infrastructure/cluster/exception/PhabricatorClusterNoHostForRoleException.php',
'PhabricatorClusterSearchConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php', 'PhabricatorClusterSearchConfigType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php',
'PhabricatorClusterServiceHealthRecord' => 'infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php', 'PhabricatorClusterServiceHealthRecord' => 'infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php',
'PhabricatorClusterStrandedException' => 'infrastructure/cluster/exception/PhabricatorClusterStrandedException.php', 'PhabricatorClusterStrandedException' => 'infrastructure/cluster/exception/PhabricatorClusterStrandedException.php',
'PhabricatorColumnProxyInterface' => 'applications/project/interface/PhabricatorColumnProxyInterface.php', 'PhabricatorColumnProxyInterface' => 'applications/project/interface/PhabricatorColumnProxyInterface.php',
@ -3199,7 +3199,7 @@ phutil_register_library_map(array(
'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php', 'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php',
'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php', 'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php',
'PhabricatorNotificationServerRef' => 'applications/notification/client/PhabricatorNotificationServerRef.php', 'PhabricatorNotificationServerRef' => 'applications/notification/client/PhabricatorNotificationServerRef.php',
'PhabricatorNotificationServersConfigOptionType' => 'applications/notification/config/PhabricatorNotificationServersConfigOptionType.php', 'PhabricatorNotificationServersConfigType' => 'applications/notification/config/PhabricatorNotificationServersConfigType.php',
'PhabricatorNotificationStatusView' => 'applications/notification/view/PhabricatorNotificationStatusView.php', 'PhabricatorNotificationStatusView' => 'applications/notification/view/PhabricatorNotificationStatusView.php',
'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php', 'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php',
'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php', 'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php',
@ -3614,7 +3614,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php', 'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php',
'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php', 'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php',
'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php', 'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php',
'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php', 'PhabricatorProjectColorsConfigType' => 'applications/project/config/PhabricatorProjectColorsConfigType.php',
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php', 'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php', 'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php',
'PhabricatorProjectColumnEditController' => 'applications/project/controller/PhabricatorProjectColumnEditController.php', 'PhabricatorProjectColumnEditController' => 'applications/project/controller/PhabricatorProjectColumnEditController.php',
@ -3652,7 +3652,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php', 'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php',
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php', 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
'PhabricatorProjectIconTransaction' => 'applications/project/xaction/PhabricatorProjectIconTransaction.php', 'PhabricatorProjectIconTransaction' => 'applications/project/xaction/PhabricatorProjectIconTransaction.php',
'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php', 'PhabricatorProjectIconsConfigType' => 'applications/project/config/PhabricatorProjectIconsConfigType.php',
'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php', 'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php',
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php', 'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
@ -7581,13 +7581,13 @@ phutil_register_library_map(array(
'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine', 'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorClassConfigType' => 'PhabricatorTextConfigType', 'PhabricatorClassConfigType' => 'PhabricatorTextConfigType',
'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorClusterDatabasesConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorClusterDatabasesConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorClusterException' => 'Exception', 'PhabricatorClusterException' => 'Exception',
'PhabricatorClusterExceptionHandler' => 'PhabricatorRequestExceptionHandler', 'PhabricatorClusterExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorClusterImpossibleWriteException' => 'PhabricatorClusterException', 'PhabricatorClusterImpossibleWriteException' => 'PhabricatorClusterException',
'PhabricatorClusterImproperWriteException' => 'PhabricatorClusterException', 'PhabricatorClusterImproperWriteException' => 'PhabricatorClusterException',
'PhabricatorClusterNoHostForRoleException' => 'Exception', 'PhabricatorClusterNoHostForRoleException' => 'Exception',
'PhabricatorClusterSearchConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorClusterSearchConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorClusterServiceHealthRecord' => 'Phobject', 'PhabricatorClusterServiceHealthRecord' => 'Phobject',
'PhabricatorClusterStrandedException' => 'PhabricatorClusterException', 'PhabricatorClusterStrandedException' => 'PhabricatorClusterException',
'PhabricatorColumnsEditField' => 'PhabricatorPHIDListEditField', 'PhabricatorColumnsEditField' => 'PhabricatorPHIDListEditField',
@ -8552,7 +8552,7 @@ phutil_register_library_map(array(
'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorNotificationServerRef' => 'Phobject', 'PhabricatorNotificationServerRef' => 'Phobject',
'PhabricatorNotificationServersConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorNotificationServersConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorNotificationStatusView' => 'AphrontTagView', 'PhabricatorNotificationStatusView' => 'AphrontTagView',
'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController',
'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory', 'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory',
@ -9065,7 +9065,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectCardView' => 'AphrontTagView', 'PhabricatorProjectCardView' => 'AphrontTagView',
'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType', 'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorProjectColorsConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorProjectColumn' => array( 'PhabricatorProjectColumn' => array(
'PhabricatorProjectDAO', 'PhabricatorProjectDAO',
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
@ -9116,7 +9116,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'PhabricatorProjectIconSet' => 'PhabricatorIconSet', 'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
'PhabricatorProjectIconTransaction' => 'PhabricatorProjectTransactionType', 'PhabricatorProjectIconTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorProjectIconsConfigType' => 'PhabricatorJSONConfigType',
'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType', 'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectListController' => 'PhabricatorProjectController', 'PhabricatorProjectListController' => 'PhabricatorProjectController',
'PhabricatorProjectListView' => 'AphrontView', 'PhabricatorProjectListView' => 'AphrontView',

View file

@ -20,7 +20,7 @@ final class PhabricatorClusterConfigOptions
} }
public function getOptions() { public function getOptions() {
$databases_type = 'custom:PhabricatorClusterDatabasesConfigOptionType'; $databases_type = 'cluster.databases';
$databases_help = $this->deformat(pht(<<<EOTEXT $databases_help = $this->deformat(pht(<<<EOTEXT
WARNING: This is a prototype option and the description below is currently pure WARNING: This is a prototype option and the description below is currently pure
fantasy. fantasy.
@ -38,7 +38,7 @@ EOTEXT
$intro_href = PhabricatorEnv::getDoclink('Clustering Introduction'); $intro_href = PhabricatorEnv::getDoclink('Clustering Introduction');
$intro_name = pht('Clustering Introduction'); $intro_name = pht('Clustering Introduction');
$search_type = 'custom:PhabricatorClusterSearchConfigOptionType'; $search_type = 'cluster.search';
$search_help = $this->deformat(pht(<<<EOTEXT $search_help = $this->deformat(pht(<<<EOTEXT
Define one or more fulltext storage services. Here you can configure which Define one or more fulltext storage services. Here you can configure which
hosts will handle fulltext search queries and indexing. For help with hosts will handle fulltext search queries and indexing. For help with

View file

@ -20,7 +20,7 @@ final class PhabricatorNotificationConfigOptions
} }
public function getOptions() { public function getOptions() {
$servers_type = 'custom:PhabricatorNotificationServersConfigOptionType'; $servers_type = 'cluster.notifications';
$servers_help = $this->deformat(pht(<<<EOTEXT $servers_help = $this->deformat(pht(<<<EOTEXT
Provide a list of notification servers to enable real-time notifications. Provide a list of notification servers to enable real-time notifications.

View file

@ -29,10 +29,6 @@ abstract class PhabricatorConfigType extends Phobject {
abstract protected function newHTTPParameterType(); abstract protected function newHTTPParameterType();
public function validateValue(PhabricatorConfigOption $option, $value) {
return array();
}
public function newTransaction( public function newTransaction(
PhabricatorConfigOption $option, PhabricatorConfigOption $option,
$value) { $value) {

View file

@ -1,19 +1,17 @@
<?php <?php
final class PhabricatorNotificationServersConfigOptionType final class PhabricatorNotificationServersConfigType
extends PhabricatorConfigJSONOptionType { extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) { const TYPEKEY = 'cluster.notifications';
if (!is_array($value)) {
throw new Exception( public function validateStoredValue(
pht( PhabricatorConfigOption $option,
'Notification server configuration is not valid: value must be a '. $value) {
'list of servers'));
}
foreach ($value as $index => $spec) { foreach ($value as $index => $spec) {
if (!is_array($spec)) { if (!is_array($spec)) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration is not valid: each entry in '. 'Notification server configuration is not valid: each entry in '.
'the list must be a dictionary describing a service, but '. 'the list must be a dictionary describing a service, but '.
@ -38,7 +36,7 @@ final class PhabricatorNotificationServersConfigOptionType
'disabled' => 'optional bool', 'disabled' => 'optional bool',
)); ));
} catch (Exception $ex) { } catch (Exception $ex) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration has an invalid service '. 'Notification server configuration has an invalid service '.
'specification (at index "%s"): %s.', 'specification (at index "%s"): %s.',
@ -64,7 +62,7 @@ final class PhabricatorNotificationServersConfigOptionType
} }
break; break;
default: default:
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration describes an invalid '. 'Notification server configuration describes an invalid '.
'host ("%s", at index "%s") with an unrecognized type ("%s"). '. 'host ("%s", at index "%s") with an unrecognized type ("%s"). '.
@ -81,7 +79,7 @@ final class PhabricatorNotificationServersConfigOptionType
case 'https': case 'https':
break; break;
default: default:
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration describes an invalid '. 'Notification server configuration describes an invalid '.
'host ("%s", at index "%s") with an invalid protocol ("%s"). '. 'host ("%s", at index "%s") with an invalid protocol ("%s"). '.
@ -95,7 +93,7 @@ final class PhabricatorNotificationServersConfigOptionType
$path = idx($spec, 'path'); $path = idx($spec, 'path');
if ($type == 'admin' && strlen($path)) { if ($type == 'admin' && strlen($path)) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration describes an invalid host '. 'Notification server configuration describes an invalid host '.
'("%s", at index "%s"). This is an "admin" service but it has a '. '("%s", at index "%s"). This is an "admin" service but it has a '.
@ -108,7 +106,7 @@ final class PhabricatorNotificationServersConfigOptionType
// mistakes. // mistakes.
$key = "{$host}:{$port}"; $key = "{$host}:{$port}";
if (isset($map[$key])) { if (isset($map[$key])) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration is invalid: it describes the '. 'Notification server configuration is invalid: it describes the '.
'same host and port ("%s") multiple times. Each host and port '. 'same host and port ("%s") multiple times. Each host and port '.
@ -120,7 +118,7 @@ final class PhabricatorNotificationServersConfigOptionType
if ($value) { if ($value) {
if (!$has_admin) { if (!$has_admin) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration is invalid: it does not '. 'Notification server configuration is invalid: it does not '.
'specify any enabled servers with type "admin". Notifications '. 'specify any enabled servers with type "admin". Notifications '.
@ -128,7 +126,7 @@ final class PhabricatorNotificationServersConfigOptionType
} }
if (!$has_client) { if (!$has_client) {
throw new Exception( throw $this->newException(
pht( pht(
'Notification server configuration is invalid: it does not '. 'Notification server configuration is invalid: it does not '.
'specify any enabled servers with type "client". Notifications '. 'specify any enabled servers with type "client". Notifications '.

View file

@ -1,10 +0,0 @@
<?php
final class PhabricatorProjectColorsConfigOptionType
extends PhabricatorConfigJSONOptionType {
public function validateOption(PhabricatorConfigOption $option, $value) {
PhabricatorProjectIconSet::validateColorConfiguration($value);
}
}

View file

@ -0,0 +1,14 @@
<?php
final class PhabricatorProjectColorsConfigType
extends PhabricatorJSONConfigType {
const TYPEKEY = 'project.colors';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
PhabricatorProjectIconSet::validateColorConfiguration($value);
}
}

View file

@ -21,7 +21,7 @@ final class PhabricatorProjectConfigOptions
public function getOptions() { public function getOptions() {
$default_icons = PhabricatorProjectIconSet::getDefaultConfiguration(); $default_icons = PhabricatorProjectIconSet::getDefaultConfiguration();
$icons_type = 'custom:PhabricatorProjectIconsConfigOptionType'; $icons_type = 'project.icons';
$icons_description = $this->deformat(pht(<<<EOTEXT $icons_description = $this->deformat(pht(<<<EOTEXT
Allows you to change and customize the available project icons. Allows you to change and customize the available project icons.
@ -48,7 +48,7 @@ EOTEXT
)); ));
$default_colors = PhabricatorProjectIconSet::getDefaultColorMap(); $default_colors = PhabricatorProjectIconSet::getDefaultColorMap();
$colors_type = 'custom:PhabricatorProjectColorsConfigOptionType'; $colors_type = 'project.colors';
$colors_description = $this->deformat(pht(<<<EOTEXT $colors_description = $this->deformat(pht(<<<EOTEXT
Allows you to relabel project colors. Allows you to relabel project colors.

View file

@ -1,10 +0,0 @@
<?php
final class PhabricatorProjectIconsConfigOptionType
extends PhabricatorConfigJSONOptionType {
public function validateOption(PhabricatorConfigOption $option, $value) {
PhabricatorProjectIconSet::validateConfiguration($value);
}
}

View file

@ -0,0 +1,14 @@
<?php
final class PhabricatorProjectIconsConfigType
extends PhabricatorJSONConfigType {
const TYPEKEY = 'project.icons';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
PhabricatorProjectIconSet::validateConfiguration($value);
}
}

View file

@ -13,7 +13,7 @@ abstract class PhabricatorSearchManagementWorkflow
$config_value = PhabricatorEnv::getEnvConfig($config_key); $config_value = PhabricatorEnv::getEnvConfig($config_key);
try { try {
PhabricatorClusterSearchConfigOptionType::validateValue($config_value); PhabricatorClusterSearchConfigType::validateValue($config_value);
} catch (Exception $ex) { } catch (Exception $ex) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
pht( pht(

View file

@ -1,19 +1,17 @@
<?php <?php
final class PhabricatorClusterDatabasesConfigOptionType final class PhabricatorClusterDatabasesConfigType
extends PhabricatorConfigJSONOptionType { extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) { const TYPEKEY = 'cluster.databases';
if (!is_array($value)) {
throw new Exception( public function validateStoredValue(
pht( PhabricatorConfigOption $option,
'Database cluster configuration is not valid: value must be a '. $value) {
'list of database hosts.'));
}
foreach ($value as $index => $spec) { foreach ($value as $index => $spec) {
if (!is_array($spec)) { if (!is_array($spec)) {
throw new Exception( throw $this->newException(
pht( pht(
'Database cluster configuration is not valid: each entry in the '. 'Database cluster configuration is not valid: each entry in the '.
'list must be a dictionary describing a database host, but '. 'list must be a dictionary describing a database host, but '.
@ -40,7 +38,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
'persistent' => 'optional bool', 'persistent' => 'optional bool',
)); ));
} catch (Exception $ex) { } catch (Exception $ex) {
throw new Exception( throw $this->newException(
pht( pht(
'Database cluster configuration has an invalid host '. 'Database cluster configuration has an invalid host '.
'specification (at index "%s"): %s.', 'specification (at index "%s"): %s.',
@ -57,7 +55,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
case 'replica': case 'replica':
break; break;
default: default:
throw new Exception( throw $this->newException(
pht( pht(
'Database cluster configuration describes an invalid '. 'Database cluster configuration describes an invalid '.
'host ("%s", at index "%s") with an unrecognized role ("%s"). '. 'host ("%s", at index "%s") with an unrecognized role ("%s"). '.
@ -78,7 +76,7 @@ final class PhabricatorClusterDatabasesConfigOptionType
// mistakes. // mistakes.
$key = "{$host}:{$port}"; $key = "{$host}:{$port}";
if (isset($map[$key])) { if (isset($map[$key])) {
throw new Exception( throw $this->newException(
pht( pht(
'Database cluster configuration is invalid: it describes the '. 'Database cluster configuration is invalid: it describes the '.
'same host ("%s") multiple times. Each host should appear only '. 'same host ("%s") multiple times. Each host should appear only '.

View file

@ -1,20 +1,17 @@
<?php <?php
final class PhabricatorClusterSearchConfigOptionType final class PhabricatorClusterSearchConfigType
extends PhabricatorConfigJSONOptionType { extends PhabricatorJSONConfigType {
public function validateOption(PhabricatorConfigOption $option, $value) { const TYPEKEY = 'cluster.search';
public function validateStoredValue(
PhabricatorConfigOption $option,
$value) {
self::validateValue($value); self::validateValue($value);
} }
public static function validateValue($value) { public static function validateValue($value) {
if (!is_array($value)) {
throw new Exception(
pht(
'Search cluster configuration is not valid: value must be a '.
'list of search hosts.'));
}
$engines = PhabricatorSearchService::loadAllFulltextStorageEngines(); $engines = PhabricatorSearchService::loadAllFulltextStorageEngines();
foreach ($value as $index => $spec) { foreach ($value as $index => $spec) {