@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 PhrictionDocument();
4$conn_w = $table->establishConnection('w');
5
6echo pht('Populating Phriction mailkeys.')."\n";
7
8foreach (new LiskMigrationIterator($table) as $doc) {
9 $id = $doc->getID();
10
11 $key = $doc->getMailKey();
12 if ((strlen($key) == 20) && (strpos($key, "\0") === false)) {
13 // To be valid, keys must have length 20 and not contain any null bytes.
14 // See T6487.
15 echo pht('Document has valid mailkey.')."\n";
16 continue;
17 } else {
18 echo pht('Populating mailkey for document %d...', $id)."\n";
19 $mail_key = Filesystem::readRandomCharacters(20);
20 queryfx(
21 $conn_w,
22 'UPDATE %T SET mailKey = %s WHERE id = %d',
23 $table->getTableName(),
24 $mail_key,
25 $id);
26 }
27}
28
29echo pht('Done.')."\n";