@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 PhabricatorRepositoryIdentity();
4$conn = $table->establishConnection('w');
5
6$iterator = new LiskRawMigrationIterator($conn, $table->getTableName());
7foreach ($iterator as $row) {
8 $name = $row['identityNameRaw'];
9 $name = phutil_utf8ize($name);
10
11 $email = new PhutilEmailAddress($name);
12 $address = $email->getAddress();
13
14 try {
15 queryfx(
16 $conn,
17 'UPDATE %R SET emailAddress = %ns WHERE id = %d',
18 $table,
19 $address,
20 $row['id']);
21 } catch (Exception $ex) {
22 // We may occasionally run into issues with binary or very long addresses.
23 // Just skip over them.
24 continue;
25 }
26}