@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('Migrating macro authors...')."\n";
4foreach (new LiskMigrationIterator(new PhabricatorFileImageMacro()) as $macro) {
5 echo pht('Macro #%d', $macro->getID())."\n";
6
7 if ($macro->getAuthorPHID()) {
8 // Already have an author; skip it.
9 continue;
10 }
11
12 if (!$macro->getFilePHID()) {
13 // No valid file; skip it.
14 continue;
15 }
16
17 $file = id(new PhabricatorFile())->loadOneWhere(
18 'phid = %s',
19 $macro->getFilePHID());
20
21 if (!$file) {
22 // Couldn't load the file; skip it.
23 continue;
24 }
25
26 if (!$file->getAuthorPHID()) {
27 // File has no author; skip it.
28 continue;
29 }
30
31 queryfx(
32 $macro->establishConnection('w'),
33 'UPDATE %T SET authorPHID = %s WHERE id = %d',
34 $macro->getTableName(),
35 $file->getAuthorPHID(),
36 $macro->getID());
37}
38
39echo pht('Done.')."\n";