Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / resources / sql / autopatches / 20180910.audit.01.searches.php
blobf68e76fe4506ec7f1e22789dca67276593129d04
1 <?php
3 $table = new PhabricatorSavedQuery();
4 $conn = $table->establishConnection('w');
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',
15 foreach (new LiskMigrationIterator($table) as $query) {
16 if ($query->getEngineClassName() !== 'PhabricatorCommitSearchEngine') {
17 continue;
20 $parameters = $query->getParameters();
21 $status = idx($parameters, 'statuses');
23 if (!$status) {
24 // No saved "status" constraint.
25 continue;
28 if (!is_array($status)) {
29 // Saved constraint isn't a list.
30 continue;
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];
41 if ($status === $old_status) {
42 // Nothing changed.
43 continue;
46 $parameters['statuses'] = $status;
48 queryfx(
49 $conn,
50 'UPDATE %T SET parameters = %s WHERE id = %d',
51 $table->getTableName(),
52 phutil_json_encode($parameters),
53 $query->getID());