mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 19:02:41 +01:00
212d4d0dc7
Summary: Ref T2543. This migrates existing saved queries so they use the right modern values for the new tokenizer control, introduced in D18393. Test Plan: - Saved a query with "Abandoned" selected as the status in the old "<select />", prior to D18393. - Upgraded to D18393, which broke the query (it no longer selected any status filter). - Ran the migration to fix things. - Saw the query now execute with "Abandoned" selected in the tokenizer, preseving the original behavior accurately. Reviewers: chad Reviewed By: chad Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18394
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
// Migrate saved Differential revision queries from using a "<select />"
|
|
// control with hard-coded status groups for status selection to using a
|
|
// tokenizer with status functions.
|
|
|
|
$table = new PhabricatorSavedQuery();
|
|
$conn = $table->establishConnection('w');
|
|
|
|
$status_map = array(
|
|
'status-open' => array('open()'),
|
|
'status-closed' => array('closed()'),
|
|
|
|
'status-accepted' => array('accepted'),
|
|
'status-needs-review' => array('needs-review'),
|
|
'status-needs-revision' => array('needs-revision'),
|
|
'status-abandoned' => array('abandoned'),
|
|
);
|
|
|
|
foreach (new LiskMigrationIterator($table) as $query) {
|
|
if ($query->getEngineClassName() !== 'DifferentialRevisionSearchEngine') {
|
|
// This isn't a revision query.
|
|
continue;
|
|
}
|
|
|
|
$parameters = $query->getParameters();
|
|
$status = idx($parameters, 'status');
|
|
|
|
if (!$status) {
|
|
// This query didn't specify a "status" value.
|
|
continue;
|
|
}
|
|
|
|
if (!isset($status_map[$status])) {
|
|
// The "status" value is unknown, or does not correspond to a
|
|
// modern "status" constraint.
|
|
continue;
|
|
}
|
|
|
|
$parameters['statuses'] = $status_map[$status];
|
|
|
|
queryfx(
|
|
$conn,
|
|
'UPDATE %T SET parameters = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
phutil_json_encode($parameters),
|
|
$query->getID());
|
|
}
|