@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$table = new PhabricatorSavedQuery();
4$conn = $table->establishConnection('w');
5
6$status_map = array(
7 0 => 'none',
8 1 => 'needs-audit',
9 2 => 'concern-raised',
10 3 => 'partially-audited',
11 4 => 'audited',
12 5 => 'needs-verification',
13);
14
15foreach (new LiskMigrationIterator($table) as $query) {
16 if ($query->getEngineClassName() !== 'PhabricatorCommitSearchEngine') {
17 continue;
18 }
19
20 $parameters = $query->getParameters();
21 $status = idx($parameters, 'statuses');
22
23 if (!$status) {
24 // No saved "status" constraint.
25 continue;
26 }
27
28 if (!is_array($status)) {
29 // Saved constraint isn't a list.
30 continue;
31 }
32
33 // Migrate old integer values to new string values.
34 $old_status = $status;
35 foreach ($status as $key => $value) {
36 if (is_numeric($value)) {
37 $status[$key] = $status_map[$value];
38 }
39 }
40
41 if ($status === $old_status) {
42 // Nothing changed.
43 continue;
44 }
45
46 $parameters['statuses'] = $status;
47
48 queryfx(
49 $conn,
50 'UPDATE %T SET parameters = %s WHERE id = %d',
51 $table->getTableName(),
52 phutil_json_encode($parameters),
53 $query->getID());
54}