@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.

Fix isReadable() and isWritable() in SearchService

Summary:
Ref T12450. Minor cleanup:

- setRoles() has no callers.
- getRoles() has no callers (these two methods are leftovers from an earlier iteration of the change).
- The `hasRole()` logic doesn't work since nothing calls `setRole()`.
- `hasRole()` has only `isreadable/iswritable` as callers.
- The `isReadable()/isWritable()` logic doesn't work since `hasRole()` doesn't work.

Instead, just check if there are any readable/writable hosts. `Host` already inherits its config from `Service` so this gets the same answer without any fuss.

Also add some read/write constants to make grepping this stuff a little easier.

Test Plan:
- Grepped for all removed symbols, saw only newer-generation calls in `Host`.
- See next diff for use of `isWritable()`.

Reviewers: chad, 20after4

Reviewed By: 20after4

Maniphest Tasks: T12450

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

+5 -21
+5 -21
src/infrastructure/cluster/search/PhabricatorSearchService.php
··· 16 16 const STATUS_OKAY = 'okay'; 17 17 const STATUS_FAIL = 'fail'; 18 18 19 + const ROLE_WRITE = 'write'; 20 + const ROLE_READ = 'read'; 21 + 19 22 public function __construct(PhabricatorFulltextStorageEngine $engine) { 20 23 $this->engine = $engine; 21 24 $this->hostType = $engine->getHostType(); ··· 84 87 } 85 88 86 89 public function isWritable() { 87 - return $this->hasRole('write'); 90 + return (bool)$this->getAllHostsForRole(self::ROLE_WRITE); 88 91 } 89 92 90 93 public function isReadable() { 91 - return $this->hasRole('read'); 92 - } 93 - 94 - public function hasRole($role) { 95 - return isset($this->roles[$role]) && $this->roles[$role] !== false; 96 - } 97 - 98 - public function setRoles(array $roles) { 99 - foreach ($roles as $role => $val) { 100 - if ($val === false && isset($this->roles[$role])) { 101 - unset($this->roles[$role]); 102 - } else { 103 - $this->roles[$role] = $val; 104 - } 105 - } 106 - return $this; 107 - } 108 - 109 - public function getRoles() { 110 - return $this->roles; 94 + return (bool)$this->getAllHostsForRole(self::ROLE_READ); 111 95 } 112 96 113 97 public function getPort() {