@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+77 -80
+10 -10
src/__phutil_library_map__.php
··· 2331 2331 'PhabricatorChunkedFileStorageEngine' => 'applications/files/engine/PhabricatorChunkedFileStorageEngine.php', 2332 2332 'PhabricatorClassConfigType' => 'applications/config/type/PhabricatorClassConfigType.php', 2333 2333 'PhabricatorClusterConfigOptions' => 'applications/config/option/PhabricatorClusterConfigOptions.php', 2334 - 'PhabricatorClusterDatabasesConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php', 2334 + 'PhabricatorClusterDatabasesConfigType' => 'infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php', 2335 2335 'PhabricatorClusterException' => 'infrastructure/cluster/exception/PhabricatorClusterException.php', 2336 2336 'PhabricatorClusterExceptionHandler' => 'infrastructure/cluster/exception/PhabricatorClusterExceptionHandler.php', 2337 2337 'PhabricatorClusterImpossibleWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImpossibleWriteException.php', 2338 2338 'PhabricatorClusterImproperWriteException' => 'infrastructure/cluster/exception/PhabricatorClusterImproperWriteException.php', 2339 2339 'PhabricatorClusterNoHostForRoleException' => 'infrastructure/cluster/exception/PhabricatorClusterNoHostForRoleException.php', 2340 - 'PhabricatorClusterSearchConfigOptionType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php', 2340 + 'PhabricatorClusterSearchConfigType' => 'infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php', 2341 2341 'PhabricatorClusterServiceHealthRecord' => 'infrastructure/cluster/PhabricatorClusterServiceHealthRecord.php', 2342 2342 'PhabricatorClusterStrandedException' => 'infrastructure/cluster/exception/PhabricatorClusterStrandedException.php', 2343 2343 'PhabricatorColumnProxyInterface' => 'applications/project/interface/PhabricatorColumnProxyInterface.php', ··· 3199 3199 'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php', 3200 3200 'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php', 3201 3201 'PhabricatorNotificationServerRef' => 'applications/notification/client/PhabricatorNotificationServerRef.php', 3202 - 'PhabricatorNotificationServersConfigOptionType' => 'applications/notification/config/PhabricatorNotificationServersConfigOptionType.php', 3202 + 'PhabricatorNotificationServersConfigType' => 'applications/notification/config/PhabricatorNotificationServersConfigType.php', 3203 3203 'PhabricatorNotificationStatusView' => 'applications/notification/view/PhabricatorNotificationStatusView.php', 3204 3204 'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php', 3205 3205 'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php', ··· 3614 3614 'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php', 3615 3615 'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php', 3616 3616 'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php', 3617 - 'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php', 3617 + 'PhabricatorProjectColorsConfigType' => 'applications/project/config/PhabricatorProjectColorsConfigType.php', 3618 3618 'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php', 3619 3619 'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php', 3620 3620 'PhabricatorProjectColumnEditController' => 'applications/project/controller/PhabricatorProjectColumnEditController.php', ··· 3652 3652 'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php', 3653 3653 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php', 3654 3654 'PhabricatorProjectIconTransaction' => 'applications/project/xaction/PhabricatorProjectIconTransaction.php', 3655 - 'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php', 3655 + 'PhabricatorProjectIconsConfigType' => 'applications/project/config/PhabricatorProjectIconsConfigType.php', 3656 3656 'PhabricatorProjectImageTransaction' => 'applications/project/xaction/PhabricatorProjectImageTransaction.php', 3657 3657 'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php', 3658 3658 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', ··· 7581 7581 'PhabricatorChunkedFileStorageEngine' => 'PhabricatorFileStorageEngine', 7582 7582 'PhabricatorClassConfigType' => 'PhabricatorTextConfigType', 7583 7583 'PhabricatorClusterConfigOptions' => 'PhabricatorApplicationConfigOptions', 7584 - 'PhabricatorClusterDatabasesConfigOptionType' => 'PhabricatorConfigJSONOptionType', 7584 + 'PhabricatorClusterDatabasesConfigType' => 'PhabricatorJSONConfigType', 7585 7585 'PhabricatorClusterException' => 'Exception', 7586 7586 'PhabricatorClusterExceptionHandler' => 'PhabricatorRequestExceptionHandler', 7587 7587 'PhabricatorClusterImpossibleWriteException' => 'PhabricatorClusterException', 7588 7588 'PhabricatorClusterImproperWriteException' => 'PhabricatorClusterException', 7589 7589 'PhabricatorClusterNoHostForRoleException' => 'Exception', 7590 - 'PhabricatorClusterSearchConfigOptionType' => 'PhabricatorConfigJSONOptionType', 7590 + 'PhabricatorClusterSearchConfigType' => 'PhabricatorJSONConfigType', 7591 7591 'PhabricatorClusterServiceHealthRecord' => 'Phobject', 7592 7592 'PhabricatorClusterStrandedException' => 'PhabricatorClusterException', 7593 7593 'PhabricatorColumnsEditField' => 'PhabricatorPHIDListEditField', ··· 8552 8552 'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 8553 8553 'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine', 8554 8554 'PhabricatorNotificationServerRef' => 'Phobject', 8555 - 'PhabricatorNotificationServersConfigOptionType' => 'PhabricatorConfigJSONOptionType', 8555 + 'PhabricatorNotificationServersConfigType' => 'PhabricatorJSONConfigType', 8556 8556 'PhabricatorNotificationStatusView' => 'AphrontTagView', 8557 8557 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', 8558 8558 'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory', ··· 9065 9065 'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController', 9066 9066 'PhabricatorProjectCardView' => 'AphrontTagView', 9067 9067 'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType', 9068 - 'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType', 9068 + 'PhabricatorProjectColorsConfigType' => 'PhabricatorJSONConfigType', 9069 9069 'PhabricatorProjectColumn' => array( 9070 9070 'PhabricatorProjectDAO', 9071 9071 'PhabricatorApplicationTransactionInterface', ··· 9116 9116 'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 9117 9117 'PhabricatorProjectIconSet' => 'PhabricatorIconSet', 9118 9118 'PhabricatorProjectIconTransaction' => 'PhabricatorProjectTransactionType', 9119 - 'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType', 9119 + 'PhabricatorProjectIconsConfigType' => 'PhabricatorJSONConfigType', 9120 9120 'PhabricatorProjectImageTransaction' => 'PhabricatorProjectTransactionType', 9121 9121 'PhabricatorProjectListController' => 'PhabricatorProjectController', 9122 9122 'PhabricatorProjectListView' => 'AphrontView',
+2 -2
src/applications/config/option/PhabricatorClusterConfigOptions.php
··· 20 20 } 21 21 22 22 public function getOptions() { 23 - $databases_type = 'custom:PhabricatorClusterDatabasesConfigOptionType'; 23 + $databases_type = 'cluster.databases'; 24 24 $databases_help = $this->deformat(pht(<<<EOTEXT 25 25 WARNING: This is a prototype option and the description below is currently pure 26 26 fantasy. ··· 38 38 $intro_href = PhabricatorEnv::getDoclink('Clustering Introduction'); 39 39 $intro_name = pht('Clustering Introduction'); 40 40 41 - $search_type = 'custom:PhabricatorClusterSearchConfigOptionType'; 41 + $search_type = 'cluster.search'; 42 42 $search_help = $this->deformat(pht(<<<EOTEXT 43 43 Define one or more fulltext storage services. Here you can configure which 44 44 hosts will handle fulltext search queries and indexing. For help with
+1 -1
src/applications/config/option/PhabricatorNotificationConfigOptions.php
··· 20 20 } 21 21 22 22 public function getOptions() { 23 - $servers_type = 'custom:PhabricatorNotificationServersConfigOptionType'; 23 + $servers_type = 'cluster.notifications'; 24 24 $servers_help = $this->deformat(pht(<<<EOTEXT 25 25 Provide a list of notification servers to enable real-time notifications. 26 26
-4
src/applications/config/type/PhabricatorConfigType.php
··· 29 29 30 30 abstract protected function newHTTPParameterType(); 31 31 32 - public function validateValue(PhabricatorConfigOption $option, $value) { 33 - return array(); 34 - } 35 - 36 32 public function newTransaction( 37 33 PhabricatorConfigOption $option, 38 34 $value) {
+15 -17
src/applications/notification/config/PhabricatorNotificationServersConfigOptionType.php src/applications/notification/config/PhabricatorNotificationServersConfigType.php
··· 1 1 <?php 2 2 3 - final class PhabricatorNotificationServersConfigOptionType 4 - extends PhabricatorConfigJSONOptionType { 3 + final class PhabricatorNotificationServersConfigType 4 + extends PhabricatorJSONConfigType { 5 5 6 - public function validateOption(PhabricatorConfigOption $option, $value) { 7 - if (!is_array($value)) { 8 - throw new Exception( 9 - pht( 10 - 'Notification server configuration is not valid: value must be a '. 11 - 'list of servers')); 12 - } 6 + const TYPEKEY = 'cluster.notifications'; 7 + 8 + public function validateStoredValue( 9 + PhabricatorConfigOption $option, 10 + $value) { 13 11 14 12 foreach ($value as $index => $spec) { 15 13 if (!is_array($spec)) { 16 - throw new Exception( 14 + throw $this->newException( 17 15 pht( 18 16 'Notification server configuration is not valid: each entry in '. 19 17 'the list must be a dictionary describing a service, but '. ··· 38 36 'disabled' => 'optional bool', 39 37 )); 40 38 } catch (Exception $ex) { 41 - throw new Exception( 39 + throw $this->newException( 42 40 pht( 43 41 'Notification server configuration has an invalid service '. 44 42 'specification (at index "%s"): %s.', ··· 64 62 } 65 63 break; 66 64 default: 67 - throw new Exception( 65 + throw $this->newException( 68 66 pht( 69 67 'Notification server configuration describes an invalid '. 70 68 'host ("%s", at index "%s") with an unrecognized type ("%s"). '. ··· 81 79 case 'https': 82 80 break; 83 81 default: 84 - throw new Exception( 82 + throw $this->newException( 85 83 pht( 86 84 'Notification server configuration describes an invalid '. 87 85 'host ("%s", at index "%s") with an invalid protocol ("%s"). '. ··· 95 93 96 94 $path = idx($spec, 'path'); 97 95 if ($type == 'admin' && strlen($path)) { 98 - throw new Exception( 96 + throw $this->newException( 99 97 pht( 100 98 'Notification server configuration describes an invalid host '. 101 99 '("%s", at index "%s"). This is an "admin" service but it has a '. ··· 108 106 // mistakes. 109 107 $key = "{$host}:{$port}"; 110 108 if (isset($map[$key])) { 111 - throw new Exception( 109 + throw $this->newException( 112 110 pht( 113 111 'Notification server configuration is invalid: it describes the '. 114 112 'same host and port ("%s") multiple times. Each host and port '. ··· 120 118 121 119 if ($value) { 122 120 if (!$has_admin) { 123 - throw new Exception( 121 + throw $this->newException( 124 122 pht( 125 123 'Notification server configuration is invalid: it does not '. 126 124 'specify any enabled servers with type "admin". Notifications '. ··· 128 126 } 129 127 130 128 if (!$has_client) { 131 - throw new Exception( 129 + throw $this->newException( 132 130 pht( 133 131 'Notification server configuration is invalid: it does not '. 134 132 'specify any enabled servers with type "client". Notifications '.
-10
src/applications/project/config/PhabricatorProjectColorsConfigOptionType.php
··· 1 - <?php 2 - 3 - final class PhabricatorProjectColorsConfigOptionType 4 - extends PhabricatorConfigJSONOptionType { 5 - 6 - public function validateOption(PhabricatorConfigOption $option, $value) { 7 - PhabricatorProjectIconSet::validateColorConfiguration($value); 8 - } 9 - 10 - }
+14
src/applications/project/config/PhabricatorProjectColorsConfigType.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectColorsConfigType 4 + extends PhabricatorJSONConfigType { 5 + 6 + const TYPEKEY = 'project.colors'; 7 + 8 + public function validateStoredValue( 9 + PhabricatorConfigOption $option, 10 + $value) { 11 + PhabricatorProjectIconSet::validateColorConfiguration($value); 12 + } 13 + 14 + }
+2 -2
src/applications/project/config/PhabricatorProjectConfigOptions.php
··· 21 21 22 22 public function getOptions() { 23 23 $default_icons = PhabricatorProjectIconSet::getDefaultConfiguration(); 24 - $icons_type = 'custom:PhabricatorProjectIconsConfigOptionType'; 24 + $icons_type = 'project.icons'; 25 25 26 26 $icons_description = $this->deformat(pht(<<<EOTEXT 27 27 Allows you to change and customize the available project icons. ··· 48 48 )); 49 49 50 50 $default_colors = PhabricatorProjectIconSet::getDefaultColorMap(); 51 - $colors_type = 'custom:PhabricatorProjectColorsConfigOptionType'; 51 + $colors_type = 'project.colors'; 52 52 53 53 $colors_description = $this->deformat(pht(<<<EOTEXT 54 54 Allows you to relabel project colors.
-10
src/applications/project/config/PhabricatorProjectIconsConfigOptionType.php
··· 1 - <?php 2 - 3 - final class PhabricatorProjectIconsConfigOptionType 4 - extends PhabricatorConfigJSONOptionType { 5 - 6 - public function validateOption(PhabricatorConfigOption $option, $value) { 7 - PhabricatorProjectIconSet::validateConfiguration($value); 8 - } 9 - 10 - }
+14
src/applications/project/config/PhabricatorProjectIconsConfigType.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectIconsConfigType 4 + extends PhabricatorJSONConfigType { 5 + 6 + const TYPEKEY = 'project.icons'; 7 + 8 + public function validateStoredValue( 9 + PhabricatorConfigOption $option, 10 + $value) { 11 + PhabricatorProjectIconSet::validateConfiguration($value); 12 + } 13 + 14 + }
+1 -1
src/applications/search/management/PhabricatorSearchManagementWorkflow.php
··· 13 13 $config_value = PhabricatorEnv::getEnvConfig($config_key); 14 14 15 15 try { 16 - PhabricatorClusterSearchConfigOptionType::validateValue($config_value); 16 + PhabricatorClusterSearchConfigType::validateValue($config_value); 17 17 } catch (Exception $ex) { 18 18 throw new PhutilArgumentUsageException( 19 19 pht(
+11 -13
src/infrastructure/cluster/config/PhabricatorClusterDatabasesConfigOptionType.php src/infrastructure/cluster/config/PhabricatorClusterDatabasesConfigType.php
··· 1 1 <?php 2 2 3 - final class PhabricatorClusterDatabasesConfigOptionType 4 - extends PhabricatorConfigJSONOptionType { 3 + final class PhabricatorClusterDatabasesConfigType 4 + extends PhabricatorJSONConfigType { 5 5 6 - public function validateOption(PhabricatorConfigOption $option, $value) { 7 - if (!is_array($value)) { 8 - throw new Exception( 9 - pht( 10 - 'Database cluster configuration is not valid: value must be a '. 11 - 'list of database hosts.')); 12 - } 6 + const TYPEKEY = 'cluster.databases'; 7 + 8 + public function validateStoredValue( 9 + PhabricatorConfigOption $option, 10 + $value) { 13 11 14 12 foreach ($value as $index => $spec) { 15 13 if (!is_array($spec)) { 16 - throw new Exception( 14 + throw $this->newException( 17 15 pht( 18 16 'Database cluster configuration is not valid: each entry in the '. 19 17 'list must be a dictionary describing a database host, but '. ··· 40 38 'persistent' => 'optional bool', 41 39 )); 42 40 } catch (Exception $ex) { 43 - throw new Exception( 41 + throw $this->newException( 44 42 pht( 45 43 'Database cluster configuration has an invalid host '. 46 44 'specification (at index "%s"): %s.', ··· 57 55 case 'replica': 58 56 break; 59 57 default: 60 - throw new Exception( 58 + throw $this->newException( 61 59 pht( 62 60 'Database cluster configuration describes an invalid '. 63 61 'host ("%s", at index "%s") with an unrecognized role ("%s"). '. ··· 78 76 // mistakes. 79 77 $key = "{$host}:{$port}"; 80 78 if (isset($map[$key])) { 81 - throw new Exception( 79 + throw $this->newException( 82 80 pht( 83 81 'Database cluster configuration is invalid: it describes the '. 84 82 'same host ("%s") multiple times. Each host should appear only '.
+7 -10
src/infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php src/infrastructure/cluster/config/PhabricatorClusterSearchConfigType.php
··· 1 1 <?php 2 2 3 - final class PhabricatorClusterSearchConfigOptionType 4 - extends PhabricatorConfigJSONOptionType { 3 + final class PhabricatorClusterSearchConfigType 4 + extends PhabricatorJSONConfigType { 5 + 6 + const TYPEKEY = 'cluster.search'; 5 7 6 - public function validateOption(PhabricatorConfigOption $option, $value) { 8 + public function validateStoredValue( 9 + PhabricatorConfigOption $option, 10 + $value) { 7 11 self::validateValue($value); 8 12 } 9 13 10 14 public static function validateValue($value) { 11 - if (!is_array($value)) { 12 - throw new Exception( 13 - pht( 14 - 'Search cluster configuration is not valid: value must be a '. 15 - 'list of search hosts.')); 16 - } 17 - 18 15 $engines = PhabricatorSearchService::loadAllFulltextStorageEngines(); 19 16 20 17 foreach ($value as $index => $spec) {