@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$policies = array(
4 'Administrators',
5 'LegalpadSignature',
6 'LunarPhase',
7 'Projects',
8 'Users',
9);
10$map = array();
11
12foreach ($policies as $policy) {
13 $old_name = "PhabricatorPolicyRule{$policy}";
14 $new_name = "Phabricator{$policy}PolicyRule";
15 $map[$old_name] = $new_name;
16}
17
18echo pht('Migrating policies...')."\n";
19$table = new PhabricatorPolicy();
20$conn_w = $table->establishConnection('w');
21
22foreach (new LiskMigrationIterator($table) as $policy) {
23 $old_rules = $policy->getRules();
24 $new_rules = array();
25
26 foreach ($old_rules as $rule) {
27 $existing_rule = $rule['rule'];
28 $rule['rule'] = idx($map, $existing_rule, $existing_rule);
29 $new_rules[] = $rule;
30 }
31
32 queryfx(
33 $conn_w,
34 'UPDATE %T SET rules = %s WHERE id = %d',
35 $table->getTableName(),
36 json_encode($new_rules),
37 $policy->getID());
38}