@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Continue modernizing application access to user preferences

Summary:
Ref T4103. This is just incremental cleanup:

- Add "internal" settings, which aren't editable via the UI. They can still do validation and run through the normal pathway. Move a couple settings to use this.
- Remove `getPreference()` on `PhabricatorUser`, which was a sort of prototype version of `getUserSetting()`.
- Make `getUserSetting()` validate setting values before returning them, to improve robustness if we change allowable values later.
- Add a user setting cache, since reading user settings was getting fairly expensive on Calendar.
- Improve performance of setting validation for timezone setting (don't require building/computing all timezone offsets).
- Since we have the cache anyway, make the timezone override a little more general in its approach.
- Move editor stuff to use `getUserSetting()`.

Test Plan:
- Changed search scopes.
- Reconciled local and server timezone settings by ignoring and changing timezones.
- Changed date/time settings, browsed Calendar, queried date ranges.
- Verified editor links generate properly in Diffusion.
- Browsed around with time/date settings looking at timestamps.
- Grepped for `getPreference()`, nuked all the ones coming off `$user` or `$viewer` that I could find.
- Changed accessiblity to high-contrast colors.
- Ran all unit tests.
- Grepped for removed constants.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103

Differential Revision: https://secure.phabricator.com/D16015

+168 -97
+6
src/__phutil_library_map__.php
··· 2594 2594 'PhabricatorInlineCommentPreviewController' => 'infrastructure/diff/PhabricatorInlineCommentPreviewController.php', 2595 2595 'PhabricatorInlineSummaryView' => 'infrastructure/diff/view/PhabricatorInlineSummaryView.php', 2596 2596 'PhabricatorInstructionsEditField' => 'applications/transactions/editfield/PhabricatorInstructionsEditField.php', 2597 + 'PhabricatorInternalSetting' => 'applications/settings/setting/PhabricatorInternalSetting.php', 2597 2598 'PhabricatorInternationalizationManagementExtractWorkflow' => 'infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php', 2598 2599 'PhabricatorInternationalizationManagementWorkflow' => 'infrastructure/internationalization/management/PhabricatorInternationalizationManagementWorkflow.php', 2599 2600 'PhabricatorInvalidConfigSetupCheck' => 'applications/config/check/PhabricatorInvalidConfigSetupCheck.php', ··· 3353 3354 'PhabricatorSearchResultBucketGroup' => 'applications/search/buckets/PhabricatorSearchResultBucketGroup.php', 3354 3355 'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php', 3355 3356 'PhabricatorSearchSchemaSpec' => 'applications/search/storage/PhabricatorSearchSchemaSpec.php', 3357 + 'PhabricatorSearchScopeSetting' => 'applications/settings/setting/PhabricatorSearchScopeSetting.php', 3356 3358 'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php', 3357 3359 'PhabricatorSearchSelectField' => 'applications/search/field/PhabricatorSearchSelectField.php', 3358 3360 'PhabricatorSearchStringListField' => 'applications/search/field/PhabricatorSearchStringListField.php', ··· 3538 3540 'PhabricatorTimeFormatSetting' => 'applications/settings/setting/PhabricatorTimeFormatSetting.php', 3539 3541 'PhabricatorTimeGuard' => 'infrastructure/time/PhabricatorTimeGuard.php', 3540 3542 'PhabricatorTimeTestCase' => 'infrastructure/time/__tests__/PhabricatorTimeTestCase.php', 3543 + 'PhabricatorTimezoneIgnoreOffsetSetting' => 'applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php', 3541 3544 'PhabricatorTimezoneSetting' => 'applications/settings/setting/PhabricatorTimezoneSetting.php', 3542 3545 'PhabricatorTimezoneSetupCheck' => 'applications/config/check/PhabricatorTimezoneSetupCheck.php', 3543 3546 'PhabricatorTitleGlyphsSetting' => 'applications/settings/setting/PhabricatorTitleGlyphsSetting.php', ··· 7196 7199 'PhabricatorInlineCommentPreviewController' => 'PhabricatorController', 7197 7200 'PhabricatorInlineSummaryView' => 'AphrontView', 7198 7201 'PhabricatorInstructionsEditField' => 'PhabricatorEditField', 7202 + 'PhabricatorInternalSetting' => 'PhabricatorSetting', 7199 7203 'PhabricatorInternationalizationManagementExtractWorkflow' => 'PhabricatorInternationalizationManagementWorkflow', 7200 7204 'PhabricatorInternationalizationManagementWorkflow' => 'PhabricatorManagementWorkflow', 7201 7205 'PhabricatorInvalidConfigSetupCheck' => 'PhabricatorSetupCheck', ··· 8103 8107 'PhabricatorSearchResultBucketGroup' => 'Phobject', 8104 8108 'PhabricatorSearchResultView' => 'AphrontView', 8105 8109 'PhabricatorSearchSchemaSpec' => 'PhabricatorConfigSchemaSpec', 8110 + 'PhabricatorSearchScopeSetting' => 'PhabricatorInternalSetting', 8106 8111 'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController', 8107 8112 'PhabricatorSearchSelectField' => 'PhabricatorSearchField', 8108 8113 'PhabricatorSearchStringListField' => 'PhabricatorSearchField', ··· 8304 8309 'PhabricatorTimeFormatSetting' => 'PhabricatorSelectSetting', 8305 8310 'PhabricatorTimeGuard' => 'Phobject', 8306 8311 'PhabricatorTimeTestCase' => 'PhabricatorTestCase', 8312 + 'PhabricatorTimezoneIgnoreOffsetSetting' => 'PhabricatorInternalSetting', 8307 8313 'PhabricatorTimezoneSetting' => 'PhabricatorOptionGroupSetting', 8308 8314 'PhabricatorTimezoneSetupCheck' => 'PhabricatorSetupCheck', 8309 8315 'PhabricatorTitleGlyphsSetting' => 'PhabricatorSelectSetting',
+2 -2
src/aphront/response/AphrontAjaxResponse.php
··· 64 64 if ($request) { 65 65 $viewer = $request->getViewer(); 66 66 if ($viewer) { 67 - $postprocessor_key = $viewer->getPreference( 68 - PhabricatorUserPreferences::PREFERENCE_RESOURCE_POSTPROCESSOR); 67 + $postprocessor_key = $viewer->getUserSetting( 68 + PhabricatorAccessibilitySetting::SETTINGKEY); 69 69 if (strlen($postprocessor_key)) { 70 70 $response->setPostprocessorKey($postprocessor_key); 71 71 }
+63 -53
src/applications/people/storage/PhabricatorUser.php
··· 66 66 private $authorities = array(); 67 67 private $handlePool; 68 68 private $csrfSalt; 69 - private $timezoneOverride; 69 + 70 + private $settingCacheKeys = array(); 71 + private $settingCache = array(); 70 72 71 73 protected function readField($field) { 72 74 switch ($field) { ··· 481 483 482 484 483 485 public function getUserSetting($key) { 486 + // NOTE: We store available keys and cached values separately to make it 487 + // faster to check for `null` in the cache, which is common. 488 + if (isset($this->settingCacheKeys[$key])) { 489 + return $this->settingCache[$key]; 490 + } 491 + 484 492 $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; 485 493 $settings = $this->requireCacheData($settings_key); 486 494 495 + $defaults = PhabricatorSetting::getAllEnabledSettings($this); 496 + 487 497 if (array_key_exists($key, $settings)) { 488 - return $settings[$key]; 498 + $value = $settings[$key]; 499 + 500 + // Make sure the value is valid before we return it. This makes things 501 + // more robust when options are changed or removed. 502 + if (isset($defaults[$key])) { 503 + try { 504 + id(clone $defaults[$key]) 505 + ->setViewer($this) 506 + ->assertValidValue($value); 507 + 508 + $this->settingCacheKeys[$key] = true; 509 + $this->settingCache[$key] = $value; 510 + 511 + return $value; 512 + } catch (Exception $ex) { 513 + // Fall through below and return the default value. 514 + } 515 + } 489 516 } 490 517 491 - $defaults = PhabricatorSetting::getAllEnabledSettings($this); 492 518 if (isset($defaults[$key])) { 493 - return $defaults[$key]->getSettingDefaultValue(); 519 + $value = id(clone $defaults[$key]) 520 + ->setViewer($this) 521 + ->getSettingDefaultValue(); 522 + } else { 523 + $value = null; 494 524 } 495 525 496 - return null; 526 + $this->settingCacheKeys[$key] = true; 527 + $this->settingCache[$key] = $value; 528 + 529 + return $value; 497 530 } 498 531 499 532 ··· 510 543 return ($actual == $value); 511 544 } 512 545 546 + 547 + /** 548 + * @task settings 549 + */ 550 + public function clearUserSettingCache() { 551 + $this->settingCacheKeys = array(); 552 + $this->settingCache = array(); 553 + 554 + $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; 555 + $this->clearCacheData($settings_key); 556 + 557 + return $this; 558 + } 559 + 513 560 public function getTranslation() { 514 561 return $this->getUserSetting(PhabricatorTranslationSetting::SETTINGKEY); 515 562 } 516 563 517 564 public function getTimezoneIdentifier() { 518 - if ($this->timezoneOverride) { 519 - return $this->timezoneOverride; 520 - } 521 - 522 565 return $this->getUserSetting(PhabricatorTimezoneSetting::SETTINGKEY); 523 566 } 524 567 ··· 533 576 * @task settings 534 577 */ 535 578 public function overrideTimezoneIdentifier($identifier) { 536 - $this->timezoneOverride = $identifier; 579 + $timezone_key = PhabricatorTimezoneSetting::SETTINGKEY; 580 + $this->settingCacheKeys[$timezone_key] = true; 581 + $this->settingCache[$timezone_key] = $identifier; 537 582 return $this; 538 583 } 539 584 ··· 578 623 $line, 579 624 PhabricatorRepository $repository = null) { 580 625 581 - $editor = $this->loadPreferences()->getPreference( 582 - PhabricatorUserPreferences::PREFERENCE_EDITOR); 626 + $editor = $this->getUserSetting(PhabricatorEditorSetting::SETTINGKEY); 583 627 584 628 if (is_array($path)) { 585 - $multiedit = $this->loadPreferences()->getPreference( 586 - PhabricatorUserPreferences::PREFERENCE_MULTIEDIT); 629 + $multi_key = PhabricatorEditorMultipleSetting::SETTINGKEY; 630 + $multiedit = $this->getUserSetting($multi_key); 587 631 switch ($multiedit) { 588 - case '': 632 + case PhabricatorEditorMultipleSetting::VALUE_SPACES: 589 633 $path = implode(' ', $path); 590 634 break; 591 - case 'disable': 635 + case PhabricatorEditorMultipleSetting::VALUE_SINGLE: 636 + default: 592 637 return null; 593 638 } 594 639 } ··· 848 893 $format = 'M j'; 849 894 } else { 850 895 // Same year, month and day so show a time of day. 851 - $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 852 - $format = $this->getPreference($pref_time); 896 + $pref_time = PhabricatorTimeFormatSetting::SETTINGKEY; 897 + $format = $this->getUserSetting($pref_time); 853 898 } 854 899 855 900 return $when->format($format); 856 - } 857 - 858 - public function getPreference($key) { 859 - $preferences = $this->loadPreferences(); 860 - 861 - // TODO: After T4103 and T7707 this should eventually be pushed down the 862 - // stack into modular preference definitions and role profiles. This is 863 - // just fixing T8601 and mildly anticipating those changes. 864 - $value = $preferences->getPreference($key); 865 - 866 - $allowed_values = null; 867 - switch ($key) { 868 - case PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT: 869 - $allowed_values = array( 870 - 'g:i A', 871 - 'H:i', 872 - ); 873 - break; 874 - case PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT: 875 - $allowed_values = array( 876 - 'Y-m-d', 877 - 'n/j/Y', 878 - 'd-m-Y', 879 - ); 880 - break; 881 - } 882 - 883 - if ($allowed_values !== null) { 884 - $allowed_values = array_fuse($allowed_values); 885 - if (empty($allowed_values[$value])) { 886 - $value = head($allowed_values); 887 - } 888 - } 889 - 890 - return $value; 891 901 } 892 902 893 903 public function __toString() {
+2 -3
src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
··· 30 30 if ($request->isFormPost()) { 31 31 $timezone = $request->getStr('timezone'); 32 32 33 - $pref_ignore = PhabricatorUserPreferences::PREFERENCE_IGNORE_OFFSET; 33 + $pref_ignore = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY; 34 34 $pref_timezone = PhabricatorTimezoneSetting::SETTINGKEY; 35 35 36 36 $preferences = $viewer->loadPreferences(); ··· 56 56 ->setPreference($pref_timezone, $timezone) 57 57 ->save(); 58 58 59 - $viewer->clearCacheData( 60 - PhabricatorUserPreferencesCacheType::KEY_PREFERENCES); 59 + $viewer->clearUserSettingCache(); 61 60 } 62 61 } 63 62
+1 -1
src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
··· 22 22 $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 23 23 $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT; 24 24 $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 25 - $pref_ignore = PhabricatorUserPreferences::PREFERENCE_IGNORE_OFFSET; 25 + $pref_ignore = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY; 26 26 $preferences = $user->loadPreferences(); 27 27 28 28 $errors = array();
+4
src/applications/settings/setting/PhabricatorInternalSetting.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorInternalSetting 4 + extends PhabricatorSetting {}
+16
src/applications/settings/setting/PhabricatorSearchScopeSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorSearchScopeSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'search-scope'; 7 + 8 + public function getSettingName() { 9 + return pht('Search Scope'); 10 + } 11 + 12 + public function getSettingDefaultValue() { 13 + return 'all'; 14 + } 15 + 16 + }
+4
src/applications/settings/setting/PhabricatorSetting.php
··· 89 89 return; 90 90 } 91 91 92 + public function assertValidValue($value) { 93 + $this->validateTransactionValue($value); 94 + } 95 + 92 96 public function getTransactionNewValue($value) { 93 97 return $value; 94 98 }
+12
src/applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php
··· 1 + <?php 2 + 3 + final class PhabricatorTimezoneIgnoreOffsetSetting 4 + extends PhabricatorInternalSetting { 5 + 6 + const SETTINGKEY = 'time.offset.ignore'; 7 + 8 + public function getSettingName() { 9 + return pht('Timezone Ignored Offset'); 10 + } 11 + 12 + }
+25
src/applications/settings/setting/PhabricatorTimezoneSetting.php
··· 13 13 return date_default_timezone_get(); 14 14 } 15 15 16 + public function assertValidValue($value) { 17 + // NOTE: This isn't doing anything fancy, it's just a much faster 18 + // validator than doing all the timezone calculations to build the full 19 + // list of options. 20 + 21 + if (!$value) { 22 + return; 23 + } 24 + 25 + static $identifiers; 26 + if ($identifiers === null) { 27 + $identifiers = DateTimeZone::listIdentifiers(); 28 + $identifiers = array_fuse($identifiers); 29 + } 30 + 31 + if (isset($identifiers[$value])) { 32 + return; 33 + } 34 + 35 + throw new Exception( 36 + pht( 37 + 'Timezone "%s" is not a valid timezone identiifer.', 38 + $value)); 39 + } 40 + 16 41 protected function getSelectOptionGroups() { 17 42 $timezones = DateTimeZone::listIdentifiers(); 18 43 $now = new DateTime('@'.PhabricatorTime::getNow());
-3
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 24 24 const PREFERENCE_VARY_SUBJECT = 'vary-subject'; 25 25 const PREFERENCE_HTML_EMAILS = 'html-emails'; 26 26 27 - const PREFERENCE_SEARCH_SCOPE = 'search-scope'; 28 - 29 27 const PREFERENCE_DIFFUSION_BLAME = 'diffusion-blame'; 30 28 const PREFERENCE_DIFFUSION_COLOR = 'diffusion-color'; 31 29 ··· 46 44 47 45 const PREFERENCE_PROFILE_MENU_COLLAPSED = 'profile-menu.collapsed'; 48 46 const PREFERENCE_FAVORITE_POLICIES = 'policy.favorites'; 49 - const PREFERENCE_IGNORE_OFFSET = 'time.offset.ignore'; 50 47 51 48 // These are in an unusual order for historic reasons. 52 49 const MAILTAG_PREFERENCE_NOTIFY = 0;
+10 -9
src/view/form/control/AphrontFormDateControl.php
··· 113 113 return $result; 114 114 } 115 115 116 - $readable = $this->formatTime($epoch, 'Y!m!d!g:i A'); 116 + $readable = $this->formatTime($epoch, 'Y!m!d!'.$this->getTimeFormat()); 117 117 $readable = explode('!', $readable, 4); 118 118 119 119 $year = $readable[0]; ··· 140 140 } 141 141 142 142 private function getTimeFormat() { 143 - return $this->getViewer() 144 - ->getPreference(PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT); 143 + $viewer = $this->getViewer(); 144 + $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 145 + return $viewer->getUserSetting($time_key); 145 146 } 146 147 147 148 private function getDateFormat() { 148 - return $this->getViewer() 149 - ->getPreference(PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT); 149 + $viewer = $this->getViewer(); 150 + $date_key = PhabricatorDateFormatSetting::SETTINGKEY; 151 + return $viewer->getUserSetting($date_key); 150 152 } 151 153 152 154 private function getTimeInputValue() { ··· 241 243 'format' => $this->getTimeFormat(), 242 244 )); 243 245 244 - 245 246 $time_sel = javelin_tag( 246 247 'input', 247 248 array( ··· 262 263 ), 263 264 $time_sel); 264 265 265 - $preferences = $this->getViewer()->loadPreferences(); 266 - $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 267 - $week_start = $preferences->getPreference($pref_week_start, 0); 266 + $viewer = $this->getViewer(); 267 + $week_key = PhabricatorWeekStartDaySetting::SETTINGKEY; 268 + $week_start = $viewer->getUserSetting($week_key); 268 269 269 270 Javelin::initBehavior('fancy-datepicker', array( 270 271 'format' => $this->getDateFormat(),
+6 -4
src/view/form/control/AphrontFormDateControlValue.php
··· 207 207 } 208 208 209 209 private function getTimeFormat() { 210 - return $this->getViewer() 211 - ->getPreference(PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT); 210 + $viewer = $this->getViewer(); 211 + $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 212 + return $viewer->getUserSetting($time_key); 212 213 } 213 214 214 215 private function getDateFormat() { 215 - return $this->getViewer() 216 - ->getPreference(PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT); 216 + $viewer = $this->getViewer(); 217 + $date_key = PhabricatorDateFormatSetting::SETTINGKEY; 218 + return $viewer->getUserSetting($date_key); 217 219 } 218 220 219 221 private function getFormattedDateFromDate($date, $time) {
+2 -2
src/view/page/PhabricatorBarePageView.php
··· 130 130 if ($this->getRequest()) { 131 131 $viewer = $this->getRequest()->getViewer(); 132 132 if ($viewer) { 133 - $postprocessor_key = $viewer->getPreference( 134 - PhabricatorUserPreferences::PREFERENCE_RESOURCE_POSTPROCESSOR); 133 + $postprocessor_key = $viewer->getUserSetting( 134 + PhabricatorAccessibilitySetting::SETTINGKEY); 135 135 if (strlen($postprocessor_key)) { 136 136 $response->setPostProcessorKey($postprocessor_key); 137 137 }
+2 -7
src/view/page/PhabricatorStandardPageView.php
··· 225 225 if ($user->isLoggedIn()) { 226 226 $offset = $user->getTimeZoneOffset(); 227 227 228 - $preferences = $user->loadPreferences(); 229 - $ignore_key = PhabricatorUserPreferences::PREFERENCE_IGNORE_OFFSET; 230 - 231 - $ignore = $preferences->getPreference($ignore_key); 232 - if (!strlen($ignore)) { 233 - $ignore = null; 234 - } 228 + $ignore_key = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY; 229 + $ignore = $user->getUserSetting($ignore_key); 235 230 236 231 Javelin::initBehavior( 237 232 'detect-timezone',
+3 -5
src/view/page/menu/PhabricatorMainMenuSearchView.php
··· 50 50 ''); 51 51 52 52 $search_datasource = new PhabricatorSearchDatasource(); 53 - $scope_key = PhabricatorUserPreferences::PREFERENCE_SEARCH_SCOPE; 53 + $scope_key = PhabricatorSearchScopeSetting::SETTINGKEY; 54 54 55 55 Javelin::initBehavior( 56 56 'phabricator-search-typeahead', ··· 177 177 'href' => PhabricatorEnv::getDoclink('Search User Guide'), 178 178 ); 179 179 180 - $scope_key = PhabricatorUserPreferences::PREFERENCE_SEARCH_SCOPE; 181 - $current_value = $viewer->loadPreferences()->getPreference( 182 - $scope_key, 183 - 'all'); 180 + $scope_key = PhabricatorSearchScopeSetting::SETTINGKEY; 181 + $current_value = $viewer->getUserSetting($scope_key); 184 182 185 183 $current_icon = 'fa-globe'; 186 184 foreach ($items as $item) {
+6 -4
src/view/phui/calendar/PHUICalendarListView.php
··· 147 147 } 148 148 149 149 private function getEventTooltip(AphrontCalendarEventView $event) { 150 - $time_pref = $this->getUser() 151 - ->getPreference(PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT); 150 + $viewer = $this->getViewer(); 151 + $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 152 + $time_pref = $viewer->getUserSetting($time_key); 152 153 153 154 Javelin::initBehavior('phabricator-tooltips'); 154 155 155 156 $start = id(AphrontFormDateControlValue::newFromEpoch( 156 - $this->getUser(), 157 + $viewer, 157 158 $event->getEpochStart())); 159 + 158 160 $end = id(AphrontFormDateControlValue::newFromEpoch( 159 - $this->getUser(), 161 + $viewer, 160 162 $event->getEpochEnd())); 161 163 162 164 $start_date = $start->getDateTime()->format('m d Y');
+4 -4
src/view/viewutils.php
··· 31 31 } 32 32 33 33 function phabricator_time($epoch, $user) { 34 - $time_key = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 34 + $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 35 35 return phabricator_format_local_time( 36 36 $epoch, 37 37 $user, 38 - $user->getPreference($time_key)); 38 + $user->getUserSetting($time_key)); 39 39 } 40 40 41 41 function phabricator_datetime($epoch, $user) { 42 - $time_key = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 42 + $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 43 43 return phabricator_format_local_time( 44 44 $epoch, 45 45 $user, 46 46 pht('%s, %s', 47 47 phutil_date_format($epoch), 48 - $user->getPreference($time_key))); 48 + $user->getUserSetting($time_key))); 49 49 } 50 50 51 51 /**