Add "Manual Activities", to tell administrators to rebuild the search index
Summary: Ref T11922. After updating to HEAD of `master`, you need to manually rebuild the index. We don't do this during `bin/storage upgrade` because it can take a very long time (`secure.phabricator.com` took roughly an hour) and can happen while Phabricator is running. However, if we don't warn users about this they'll just get a broken index unless they go read the changelog (or file an issue, then we tell them to go read the changelog). This adds a very simple table for notes to administrators so we can write a "you need to go rebuild the index" note, then adds one. Administrators clear the note by completing the activity and running `bin/config done reindex`. This isn't automatic because there are various strategies you can use to approach the issue, which I'll discuss in greater detail in the linked documentation. Also, fix an issue where `bin/storage upgrade --apply <patch>` could try to re-mark an already-applied patch as applied. Test Plan: - Ran storage ugrades. - Got instructions to rebuild search index. - Cleared instructions with `bin/config done reindex`. Reviewers: chad Reviewed By: chad Subscribers: avivey Maniphest Tasks: T11922 Differential Revision: https://secure.phabricator.com/D16965
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorManualActivitySetupCheck
|
||||
extends PhabricatorSetupCheck {
|
||||
|
||||
public function getDefaultGroup() {
|
||||
return self::GROUP_OTHER;
|
||||
}
|
||||
|
||||
protected function executeChecks() {
|
||||
$activities = id(new PhabricatorConfigManualActivity())->loadAll();
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
$type = $activity->getActivityType();
|
||||
|
||||
// For now, there is only one type of manual activity. It's not clear
|
||||
// if we're really going to have too much more of this stuff so this
|
||||
// is a bit under-designed for now.
|
||||
|
||||
$activity_name = pht('Rebuild Search Index');
|
||||
$activity_summary = pht(
|
||||
'The search index algorithm has been updated and the index needs '.
|
||||
'be rebuilt.');
|
||||
|
||||
$message = array();
|
||||
|
||||
$message[] = pht(
|
||||
'The indexing algorithm for the fulltext search index has been '.
|
||||
'updated and the index needs to be rebuilt. Until you rebuild the '.
|
||||
'index, global search (and other fulltext search) will not '.
|
||||
'function correctly.');
|
||||
|
||||
$message[] = pht(
|
||||
'You can rebuild the search index while Phabricator is running.');
|
||||
|
||||
$message[] = pht(
|
||||
'To rebuild the index, run this command:');
|
||||
|
||||
$message[] = phutil_tag(
|
||||
'pre',
|
||||
array(),
|
||||
(string)csprintf(
|
||||
'phabricator/ $ ./bin/search index --all --force --background'));
|
||||
|
||||
$message[] = pht(
|
||||
'You can find more information about rebuilding the search '.
|
||||
'index here: %s',
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => 'https://phurl.io/u/reindex',
|
||||
'target' => '_blank',
|
||||
),
|
||||
'https://phurl.io/u/reindex'));
|
||||
|
||||
$message[] = pht(
|
||||
'After rebuilding the index, run this command to clear this setup '.
|
||||
'warning:');
|
||||
|
||||
$message[] = phutil_tag(
|
||||
'pre',
|
||||
array(),
|
||||
(string)csprintf('phabricator/ $ ./bin/config done %R', $type));
|
||||
|
||||
$activity_message = phutil_implode_html("\n\n", $message);
|
||||
|
||||
$this->newIssue('manual.'.$type)
|
||||
->setName($activity_name)
|
||||
->setSummary($activity_summary)
|
||||
->setMessage($activity_message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorConfigManagementDoneWorkflow
|
||||
extends PhabricatorConfigManagementWorkflow {
|
||||
|
||||
protected function didConstruct() {
|
||||
$this
|
||||
->setName('done')
|
||||
->setExamples('**done** __activity__')
|
||||
->setSynopsis(pht('Mark a manual upgrade activity as complete.'))
|
||||
->setArguments(
|
||||
array(
|
||||
array(
|
||||
'name' => 'activities',
|
||||
'wildcard' => true,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$activities = $args->getArg('activities');
|
||||
if (!$activities) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht('Specify an activity to mark as completed.'));
|
||||
}
|
||||
|
||||
foreach ($activities as $type) {
|
||||
$activity = id(new PhabricatorConfigManualActivity())->loadOneWhere(
|
||||
'activityType = %s',
|
||||
$type);
|
||||
if (!$activity) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'Activity "%s" is not currently marked as required, so there '.
|
||||
'is no need to complete it.',
|
||||
$type));
|
||||
} else {
|
||||
$activity->delete();
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht(
|
||||
'Marked activity "%s" as completed.',
|
||||
$type));
|
||||
}
|
||||
}
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht('Done.'));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorConfigManualActivity
|
||||
extends PhabricatorConfigEntryDAO {
|
||||
|
||||
protected $activityType;
|
||||
protected $parameters = array();
|
||||
|
||||
const TYPE_REINDEX = 'reindex';
|
||||
|
||||
protected function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_TIMESTAMPS => false,
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'parameters' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'activityType' => 'text64',
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
'key_type' => array(
|
||||
'columns' => array('activityType'),
|
||||
'unique' => true,
|
||||
),
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function setParameter($key, $value) {
|
||||
$this->parameters[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParameter($key, $default = null) {
|
||||
return idx($this->parameters, $key, $default);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user