@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 ManiphestTask();
4$conn_w = $table->establishConnection('w');
5
6$user_table = new PhabricatorUser();
7$user_conn = $user_table->establishConnection('r');
8
9foreach (new LiskMigrationIterator($table) as $task) {
10 $id = $task->getID();
11
12 echo pht('Checking task %s...', "T{$id}")."\n";
13 $owner_phid = $task->getOwnerPHID();
14
15 if (!$owner_phid && !$task->getOwnerOrdering()) {
16 // No owner and no ordering; we're all set.
17 continue;
18 }
19
20 $owner_row = queryfx_one(
21 $user_conn,
22 'SELECT * FROM %T WHERE phid = %s',
23 $user_table->getTableName(),
24 $owner_phid);
25
26 if ($owner_row) {
27 $value = $owner_row['userName'];
28 } else {
29 $value = null;
30 }
31
32 if ($value !== $task->getOwnerOrdering()) {
33 queryfx(
34 $conn_w,
35 'UPDATE %T SET ownerOrdering = %ns WHERE id = %d',
36 $table->getTableName(),
37 $value,
38 $task->getID());
39 }
40}
41
42echo pht('Done.')."\n";