3 // Move timezone, translation and pronoun from the user object to preferences
4 // so they can be defaulted and edited like other settings.
6 $table = new PhabricatorUser();
7 $conn_w = $table->establishConnection('w');
8 $table_name = $table->getTableName();
9 $prefs_table = new PhabricatorUserPreferences();
11 foreach (new LiskRawMigrationIterator($conn_w, $table_name) as $row) {
14 $pref_row = queryfx_one(
16 'SELECT preferences FROM %T WHERE userPHID = %s',
17 $prefs_table->getTableName(),
22 $prefs = phutil_json_decode($pref_row['preferences']);
23 } catch (Exception
$ex) {
30 $zone = $row['timezoneIdentifier'];
32 $prefs[PhabricatorTimezoneSetting
::SETTINGKEY
] = $zone;
35 $pronoun = $row['sex'];
36 if (strlen($pronoun)) {
37 $prefs[PhabricatorPronounSetting
::SETTINGKEY
] = $pronoun;
40 $translation = $row['translation'];
41 if (strlen($translation)) {
42 $prefs[PhabricatorTranslationSetting
::SETTINGKEY
] = $translation;
48 'INSERT INTO %T (phid, userPHID, preferences, dateModified, dateCreated)
49 VALUES (%s, %s, %s, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())
50 ON DUPLICATE KEY UPDATE preferences = VALUES(preferences)',
51 $prefs_table->getTableName(),
52 $prefs_table->generatePHID(),
54 phutil_json_encode($prefs));
58 $prefs_key = PhabricatorUserPreferencesCacheType
::KEY_PREFERENCES
;
59 PhabricatorUserCache
::clearCacheForAllUsers($prefs_key);