@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
at recaptime-dev/main 58 lines 1.3 kB view raw
1<?php 2 3echo pht('Updating old commit authors...')."\n"; 4$table = new PhabricatorRepositoryCommit(); 5$table->openTransaction(); 6 7$conn = $table->establishConnection('w'); 8$data = new PhabricatorRepositoryCommitData(); 9$commits = queryfx_all( 10 $conn, 11 'SELECT c.id id, c.authorPHID authorPHID, d.commitDetails details 12 FROM %T c JOIN %T d ON d.commitID = c.id 13 WHERE c.authorPHID IS NULL 14 FOR UPDATE', 15 $table->getTableName(), 16 $data->getTableName()); 17 18foreach ($commits as $commit) { 19 $id = $commit['id']; 20 $details = json_decode($commit['details'], true); 21 $author_phid = idx($details, 'authorPHID'); 22 if ($author_phid) { 23 queryfx( 24 $conn, 25 'UPDATE %T SET authorPHID = %s WHERE id = %d', 26 $table->getTableName(), 27 $author_phid, 28 $id); 29 echo "#{$id}\n"; 30 } 31} 32 33$table->saveTransaction(); 34echo pht('Done.')."\n"; 35 36 37echo pht('Updating old commit %s...', 'mailKeys')."\n"; 38$table->openTransaction(); 39 40$commits = queryfx_all( 41 $conn, 42 'SELECT id FROM %T WHERE mailKey = %s FOR UPDATE', 43 $table->getTableName(), 44 ''); 45 46foreach ($commits as $commit) { 47 $id = $commit['id']; 48 queryfx( 49 $conn, 50 'UPDATE %T SET mailKey = %s WHERE id = %d', 51 $table->getTableName(), 52 Filesystem::readRandomCharacters(20), 53 $id); 54 echo "#{$id}\n"; 55} 56 57$table->saveTransaction(); 58echo pht('Done.')."\n";