@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
3echo pht(
4 "Migrating data from conpherence transactions to conpherence 'cache'...\n");
5
6$table = new ConpherenceThread();
7$table->openTransaction();
8$conn_w = $table->establishConnection('w');
9
10$participant_table = new ConpherenceParticipant();
11
12$conpherences = new LiskMigrationIterator($table);
13foreach ($conpherences as $conpherence) {
14 echo pht('Migrating conpherence #%d', $conpherence->getID())."\n";
15
16 $participants = id(new ConpherenceParticipant())
17 ->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
18
19 $transactions = id(new ConpherenceTransaction())
20 ->loadAllWhere('objectPHID = %s', $conpherence->getPHID());
21
22 $participation_hash = mgroup($participants, 'getBehindTransactionPHID');
23
24 $message_count = 0;
25 $participants_to_cache = array();
26 foreach ($transactions as $transaction) {
27 $participants_to_cache[] = $transaction->getAuthorPHID();
28 if ($transaction->getTransactionType() ==
29 PhabricatorTransactions::TYPE_COMMENT) {
30 $message_count++;
31 }
32 $participants_to_update = idx(
33 $participation_hash,
34 $transaction->getPHID(),
35 array());
36 if ($participants_to_update) {
37 queryfx(
38 $conn_w,
39 'UPDATE %T SET seenMessageCount = %d '.
40 'WHERE conpherencePHID = %s AND participantPHID IN (%Ls)',
41 $participant_table->getTableName(),
42 $message_count,
43 $conpherence->getPHID(),
44 mpull($participants_to_update, 'getParticipantPHID'));
45 }
46 }
47
48 $participants_to_cache = array_slice(
49 array_unique(array_reverse($participants_to_cache)),
50 0,
51 10);
52 queryfx(
53 $conn_w,
54 'UPDATE %T '.
55 'SET recentParticipantPHIDs = %s, '.
56 'messageCount = %d '.
57 'WHERE phid = %s',
58 $table->getTableName(),
59 json_encode($participants_to_cache),
60 $message_count,
61 $conpherence->getPHID());
62}
63
64$table->saveTransaction();
65echo "\n".pht('Done.')."\n";