mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
7ef6c0a523
Summary: Ref T4103. This isn't completely perfect but should let us move forward without also expanding scope into "too much mail". I split the existing "Mail Preferences" into two panels: a "Mail Delivery" panel for the EditEngine settings, and a "2000000 dropdowns" panel for the two million dropdowns. This one retains the old code more or less unmodified. Test Plan: - Ran unit tests, which cover most of this stuff. - Grepped for all removed constants. - Ran migrations, inspected database results. - Changed settings in both modified panels. - This covers a lot of ground, but anything I missed will hopefully be fairly obvious. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D16038
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
$table = new PhabricatorUserPreferences();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
// Convert "Mail Format", "Re Prefix" and "Vary Subjects" mail settings to
|
|
// string constants to avoid weird stuff where we store "true" and "false" as
|
|
// strings in the database.
|
|
|
|
// Each of these keys will be converted to the first value if present and
|
|
// truthy, or the second value if present and falsey.
|
|
$remap = array(
|
|
'html-emails' => array('html', 'text'),
|
|
're-prefix' => array('re', 'none'),
|
|
'vary-subject' => array('vary', 'static'),
|
|
);
|
|
|
|
foreach (new LiskMigrationIterator($table) as $row) {
|
|
$dict = $row->getPreferences();
|
|
|
|
$should_update = false;
|
|
foreach ($remap as $key => $value) {
|
|
if (isset($dict[$key])) {
|
|
if ($dict[$key]) {
|
|
$dict[$key] = $value[0];
|
|
} else {
|
|
$dict[$key] = $value[1];
|
|
}
|
|
$should_update = true;
|
|
}
|
|
}
|
|
|
|
if (!$should_update) {
|
|
continue;
|
|
}
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET preferences = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
phutil_json_encode($dict),
|
|
$row->getID());
|
|
}
|
|
|
|
$prefs_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES;
|
|
PhabricatorUserCache::clearCacheForAllUsers($prefs_key);
|