@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Re-run config validation from `bin/search`

Summary:
Ref T12450. Normally, we validate config when:

- You restart the webserver.
- You edit it with `bin/config set ...`.
- You edit it with the web UI.

However, you can also change config by editing `local.json`, `some_env.conf.php`, a `SiteConfig` class, etc. In these cases, you may miss config warnings.

Explicitly re-run search config checks from `bin/search`, similar to the additional database checks we run from `bin/storage`, to try to produce a better error message if the user has made a configuration error.

Test Plan:
```
$ ./bin/search init
Usage Exception: Setting "cluster.search" is misconfigured: Invalid search engine type: elastic. Valid types are: elasticsearch, mysql.
```

Reviewers: chad, 20after4

Reviewed By: 20after4

Maniphest Tasks: T12450

Differential Revision: https://secure.phabricator.com/D17574

+32 -2
+2
src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
··· 45 45 } 46 46 47 47 public function execute(PhutilArgumentParser $args) { 48 + $this->validateClusterSearchConfig(); 49 + 48 50 $console = PhutilConsole::getConsole(); 49 51 50 52 $is_all = $args->getArg('all');
+1
src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
··· 11 11 } 12 12 13 13 public function execute(PhutilArgumentParser $args) { 14 + $this->validateClusterSearchConfig(); 14 15 15 16 $work_done = false; 16 17 foreach (PhabricatorSearchService::getAllServices() as $service) {
+23 -1
src/applications/search/management/PhabricatorSearchManagementWorkflow.php
··· 1 1 <?php 2 2 3 3 abstract class PhabricatorSearchManagementWorkflow 4 - extends PhabricatorManagementWorkflow {} 4 + extends PhabricatorManagementWorkflow { 5 + 6 + protected function validateClusterSearchConfig() { 7 + // Configuration is normally validated by setup self-checks on the web 8 + // workflow, but users may reasonsably run `bin/search` commands after 9 + // making manual edits to "local.json". Re-verify configuration here before 10 + // continuing. 11 + 12 + $config_key = 'cluster.search'; 13 + $config_value = PhabricatorEnv::getEnvConfig($config_key); 14 + 15 + try { 16 + PhabricatorClusterSearchConfigOptionType::validateValue($config_value); 17 + } catch (Exception $ex) { 18 + throw new PhutilArgumentUsageException( 19 + pht( 20 + 'Setting "%s" is misconfigured: %s', 21 + $config_key, 22 + $ex->getMessage())); 23 + } 24 + } 25 + 26 + }
+6 -1
src/infrastructure/cluster/config/PhabricatorClusterSearchConfigOptionType.php
··· 4 4 extends PhabricatorConfigJSONOptionType { 5 5 6 6 public function validateOption(PhabricatorConfigOption $option, $value) { 7 + self::validateClusterSearchConfigValue($value); 8 + } 9 + 10 + public static function validateValue($value) { 7 11 if (!is_array($value)) { 8 12 throw new Exception( 9 13 pht( ··· 46 50 47 51 if (!array_key_exists($spec['type'], $engines)) { 48 52 throw new Exception( 49 - pht('Invalid search engine type: %s. Valid types include: %s', 53 + pht( 54 + 'Invalid search engine type: %s. Valid types are: %s.', 50 55 $spec['type'], 51 56 implode(', ', array_keys($engines)))); 52 57 }