@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('Archiving projects with no members...')."\n";
4
5$table = new PhabricatorProject();
6$table->openTransaction();
7
8foreach (new LiskMigrationIterator($table) as $project) {
9 $members = PhabricatorEdgeQuery::loadDestinationPHIDs(
10 $project->getPHID(),
11 PhabricatorProjectProjectHasMemberEdgeType::EDGECONST);
12
13 if (count($members)) {
14 echo pht(
15 'Project "%s" has %d members; skipping.',
16 $project->getName(),
17 count($members)), "\n";
18 continue;
19 }
20
21 if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
22 echo pht(
23 'Project "%s" already archived; skipping.',
24 $project->getName()), "\n";
25 continue;
26 }
27
28 echo pht('Archiving project "%s"...', $project->getName())."\n";
29 queryfx(
30 $table->establishConnection('w'),
31 'UPDATE %T SET status = %s WHERE id = %d',
32 $table->getTableName(),
33 PhabricatorProjectStatus::STATUS_ARCHIVED,
34 $project->getID());
35}
36
37$table->saveTransaction();
38echo "\n".pht('Done.')."\n";