@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<?php
2
3// Migrate saved Differential revision queries from using a "<select />"
4// control with hard-coded status groups for status selection to using a
5// tokenizer with status functions.
6
7$table = new PhabricatorSavedQuery();
8$conn = $table->establishConnection('w');
9
10$status_map = array(
11 'status-open' => array('open()'),
12 'status-closed' => array('closed()'),
13
14 'status-accepted' => array('accepted'),
15 'status-needs-review' => array('needs-review'),
16 'status-needs-revision' => array('needs-revision'),
17 'status-abandoned' => array('abandoned'),
18);
19
20foreach (new LiskMigrationIterator($table) as $query) {
21 if ($query->getEngineClassName() !== 'DifferentialRevisionSearchEngine') {
22 // This isn't a revision query.
23 continue;
24 }
25
26 $parameters = $query->getParameters();
27 $status = idx($parameters, 'status');
28
29 if (!$status) {
30 // This query didn't specify a "status" value.
31 continue;
32 }
33
34 if (!isset($status_map[$status])) {
35 // The "status" value is unknown, or does not correspond to a
36 // modern "status" constraint.
37 continue;
38 }
39
40 $parameters['statuses'] = $status_map[$status];
41
42 queryfx(
43 $conn,
44 'UPDATE %T SET parameters = %s WHERE id = %d',
45 $table->getTableName(),
46 phutil_json_encode($parameters),
47 $query->getID());
48}