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

Add migration to encourage rebuilding repository identities

Summary: Ref T12164. Defines a new manual activity that suggests rebuilding repository identities before Phabricator begins to rely on them.

Test Plan:
- Ran migration, observed expected setup issue: {F5788217}
- Ran `bin/config done identities` and observed setup issue get marked as done.
- Ran `/bin/storage upgrade --apply phabricator:20170912.ferret.01.activity.php` to make sure I didn't break the reindex migration; observed reindex setup issue appear as expected.
- Ran `./bin/config done reindex` and observed reindex issue cleared as expected.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T12164

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

+138 -45
+20
resources/sql/autopatches/20180809.repo_identities.activity.php
··· 1 + <?php 2 + 3 + // Advise installs to rebuild the repository identities. 4 + 5 + // If the install has no commits (or no commits that lack an 6 + // authorIdentityPHID), don't require a rebuild. 7 + $commits = id(new PhabricatorRepositoryCommit()) 8 + ->loadAllWhere('authorIdentityPHID IS NULL LIMIT 1'); 9 + 10 + if (!$commits) { 11 + return; 12 + } 13 + 14 + try { 15 + id(new PhabricatorConfigManualActivity()) 16 + ->setActivityType(PhabricatorConfigManualActivity::TYPE_IDENTITIES) 17 + ->save(); 18 + } catch (AphrontDuplicateKeyQueryException $ex) { 19 + // If we've already noted that this activity is required, just move on. 20 + }
+116 -45
src/applications/config/check/PhabricatorManualActivitySetupCheck.php
··· 13 13 foreach ($activities as $activity) { 14 14 $type = $activity->getActivityType(); 15 15 16 - // For now, there is only one type of manual activity. It's not clear 17 - // if we're really going to have too much more of this stuff so this 18 - // is a bit under-designed for now. 16 + switch ($type) { 17 + case PhabricatorConfigManualActivity::TYPE_REINDEX: 18 + $this->raiseSearchReindexIssue(); 19 + break; 20 + 21 + case PhabricatorConfigManualActivity::TYPE_IDENTITIES: 22 + $this->raiseRebuildIdentitiesIssue(); 23 + break; 24 + 25 + default: 26 + } 27 + } 28 + } 29 + 30 + private function raiseSearchReindexIssue() { 31 + $activity_name = pht('Rebuild Search Index'); 32 + $activity_summary = pht( 33 + 'The search index algorithm has been updated and the index needs '. 34 + 'be rebuilt.'); 35 + 36 + $message = array(); 37 + 38 + $message[] = pht( 39 + 'The indexing algorithm for the fulltext search index has been '. 40 + 'updated and the index needs to be rebuilt. Until you rebuild the '. 41 + 'index, global search (and other fulltext search) will not '. 42 + 'function correctly.'); 43 + 44 + $message[] = pht( 45 + 'You can rebuild the search index while Phabricator is running.'); 46 + 47 + $message[] = pht( 48 + 'To rebuild the index, run this command:'); 49 + 50 + $message[] = phutil_tag( 51 + 'pre', 52 + array(), 53 + (string)csprintf( 54 + 'phabricator/ $ ./bin/search index --all --force --background')); 55 + 56 + $message[] = pht( 57 + 'You can find more information about rebuilding the search '. 58 + 'index here: %s', 59 + phutil_tag( 60 + 'a', 61 + array( 62 + 'href' => 'https://phurl.io/u/reindex', 63 + 'target' => '_blank', 64 + ), 65 + 'https://phurl.io/u/reindex')); 19 66 20 - $activity_name = pht('Rebuild Search Index'); 21 - $activity_summary = pht( 22 - 'The search index algorithm has been updated and the index needs '. 23 - 'be rebuilt.'); 67 + $message[] = pht( 68 + 'After rebuilding the index, run this command to clear this setup '. 69 + 'warning:'); 24 70 25 - $message = array(); 71 + $message[] = phutil_tag( 72 + 'pre', 73 + array(), 74 + 'phabricator/ $ ./bin/config done reindex'); 26 75 27 - $message[] = pht( 28 - 'The indexing algorithm for the fulltext search index has been '. 29 - 'updated and the index needs to be rebuilt. Until you rebuild the '. 30 - 'index, global search (and other fulltext search) will not '. 31 - 'function correctly.'); 76 + $activity_message = phutil_implode_html("\n\n", $message); 77 + 78 + $this->newIssue('manual.reindex') 79 + ->setName($activity_name) 80 + ->setSummary($activity_summary) 81 + ->setMessage($activity_message); 82 + } 83 + 84 + private function raiseRebuildIdentitiesIssue() { 85 + $activity_name = pht('Rebuild Repository Identities'); 86 + $activity_summary = pht( 87 + 'The mapping from VCS users to Phabricator users has changed '. 88 + 'and must be rebuilt.'); 89 + 90 + $message = array(); 32 91 33 - $message[] = pht( 34 - 'You can rebuild the search index while Phabricator is running.'); 92 + $message[] = pht( 93 + 'The way Phabricator attributes VCS activity to Phabricator users '. 94 + 'has changed. There is a new indirection layer between the strings '. 95 + 'that appear as VCS authors and committers (such as "John Developer '. 96 + '<johnd@bigcorp.com>") and the Phabricator user that gets associated '. 97 + 'with VCS commits. This is to support situations where users '. 98 + 'are incorrectly associated with commits by Phabricator making bad '. 99 + 'guesses about the identity of the corresponding Phabricator user. '. 100 + 'This also helps with situations where existing repositories are '. 101 + 'imported without having created accounts for all the committers to '. 102 + 'that repository. Until you rebuild these repository identities, you '. 103 + 'are likely to encounter problems with future Phabricator features '. 104 + 'which will rely on the existence of these identities.'); 35 105 36 - $message[] = pht( 37 - 'To rebuild the index, run this command:'); 106 + $message[] = pht( 107 + 'You can rebuild repository identities while Phabricator is running.'); 38 108 39 - $message[] = phutil_tag( 40 - 'pre', 41 - array(), 42 - (string)csprintf( 43 - 'phabricator/ $ ./bin/search index --all --force --background')); 109 + $message[] = pht( 110 + 'To rebuild identities, run this command:'); 44 111 45 - $message[] = pht( 46 - 'You can find more information about rebuilding the search '. 47 - 'index here: %s', 48 - phutil_tag( 49 - 'a', 50 - array( 51 - 'href' => 'https://phurl.io/u/reindex', 52 - 'target' => '_blank', 53 - ), 54 - 'https://phurl.io/u/reindex')); 112 + $message[] = phutil_tag( 113 + 'pre', 114 + array(), 115 + (string)csprintf( 116 + 'phabricator/ $ ./bin/repository rebuild-identities --all')); 55 117 56 - $message[] = pht( 57 - 'After rebuilding the index, run this command to clear this setup '. 58 - 'warning:'); 118 + $message[] = pht( 119 + 'You can find more information about this new identity mapping '. 120 + 'here: %s', 121 + phutil_tag( 122 + 'a', 123 + array( 124 + 'href' => 'https://phurl.io/u/repoIdentities', 125 + 'target' => '_blank', 126 + ), 127 + 'https://phurl.io/u/repoIdentities')); 59 128 60 - $message[] = phutil_tag( 61 - 'pre', 62 - array(), 63 - (string)csprintf('phabricator/ $ ./bin/config done %R', $type)); 129 + $message[] = pht( 130 + 'After rebuilding repository identities, run this command to clear '. 131 + 'this setup warning:'); 64 132 65 - $activity_message = phutil_implode_html("\n\n", $message); 133 + $message[] = phutil_tag( 134 + 'pre', 135 + array(), 136 + 'phabricator/ $ ./bin/config done identities'); 66 137 67 - $this->newIssue('manual.'.$type) 68 - ->setName($activity_name) 69 - ->setSummary($activity_summary) 70 - ->setMessage($activity_message); 71 - } 138 + $activity_message = phutil_implode_html("\n\n", $message); 72 139 140 + $this->newIssue('manual.identities') 141 + ->setName($activity_name) 142 + ->setSummary($activity_summary) 143 + ->setMessage($activity_message); 73 144 } 74 145 75 146 }
+2
src/applications/config/storage/PhabricatorConfigManualActivity.php
··· 7 7 protected $parameters = array(); 8 8 9 9 const TYPE_REINDEX = 'reindex'; 10 + const TYPE_IDENTITIES = 'identities'; 11 + 10 12 11 13 protected function getConfiguration() { 12 14 return array(