@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
4$table = new PhabricatorUserPreferences();
5$conn_w = $table->establishConnection('w');
6
7// Convert "Mail Format", "Re Prefix" and "Vary Subjects" mail settings to
8// string constants to avoid weird stuff where we store "true" and "false" as
9// strings in the database.
10
11// Each of these keys will be converted to the first value if present and
12// truthy, or the second value if present and falsey.
13$remap = array(
14 'html-emails' => array('html', 'text'),
15 're-prefix' => array('re', 'none'),
16 'vary-subject' => array('vary', 'static'),
17);
18
19foreach (new LiskMigrationIterator($table) as $row) {
20 $dict = $row->getPreferences();
21
22 $should_update = false;
23 foreach ($remap as $key => $value) {
24 if (isset($dict[$key])) {
25 if ($dict[$key]) {
26 $dict[$key] = $value[0];
27 } else {
28 $dict[$key] = $value[1];
29 }
30 $should_update = true;
31 }
32 }
33
34 if (!$should_update) {
35 continue;
36 }
37
38 queryfx(
39 $conn_w,
40 'UPDATE %T SET preferences = %s WHERE id = %d',
41 $table->getTableName(),
42 phutil_json_encode($dict),
43 $row->getID());
44}
45
46$prefs_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES;
47PhabricatorUserCache::clearCacheForAllUsers($prefs_key);