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

Simplify user cache management of data forms

Summary: Ref T4103. Ref T10078. We currently have separate "usable" and "raw" values, but can simplify this by making `newValueForUsers()` return the raw value.

Test Plan: Ran unit tests; browsed around; dropped caches and browsed around.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103, T10078

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

+19 -23
+1 -5
src/applications/people/cache/PhabricatorUserCacheType.php
··· 27 27 } 28 28 29 29 public function getValueFromStorage($value) { 30 - return phutil_json_decode($value); 31 - } 32 - 33 - public function getValueForStorage($value) { 34 - return phutil_json_encode($value); 30 + return $value; 35 31 } 36 32 37 33 public function newValueForUsers($key, array $users) {
-4
src/applications/people/cache/PhabricatorUserMessageCountCacheType.php
··· 21 21 return (int)$value; 22 22 } 23 23 24 - public function getValueForStorage($value) { 25 - return $value; 26 - } 27 - 28 24 public function newValueForUsers($key, array $users) { 29 25 if (!$users) { 30 26 return array();
-4
src/applications/people/cache/PhabricatorUserNotificationCountCacheType.php
··· 21 21 return (int)$value; 22 22 } 23 23 24 - public function getValueForStorage($value) { 25 - return $value; 26 - } 27 - 28 24 public function newValueForUsers($key, array $users) { 29 25 if (!$users) { 30 26 return array();
+12 -2
src/applications/people/cache/PhabricatorUserPreferencesCacheType.php
··· 17 17 return ($key === self::KEY_PREFERENCES); 18 18 } 19 19 20 + public function getValueFromStorage($value) { 21 + return phutil_json_decode($value); 22 + } 23 + 20 24 public function newValueForUsers($key, array $users) { 21 25 $viewer = $this->getViewer(); 22 26 ··· 27 31 ->withUserPHIDs($user_phids) 28 32 ->execute(); 29 33 30 - $empty = array_fill_keys($user_phids, array()); 34 + $settings = mpull($preferences, 'getPreferences', 'getUserPHID'); 31 35 32 - return mpull($preferences, 'getPreferences', 'getUserPHID') + $empty; 36 + $results = array(); 37 + foreach ($user_phids as $user_phid) { 38 + $value = idx($settings, $user_phid, array()); 39 + $results[$user_phid] = phutil_json_encode($value); 40 + } 41 + 42 + return $results; 33 43 } 34 44 35 45 }
+4 -4
src/applications/people/cache/PhabricatorUserProfileImageCacheType.php
··· 17 17 return ($key === self::KEY_URI); 18 18 } 19 19 20 + public function getDefaultValue() { 21 + return PhabricatorUser::getDefaultProfileImageURI(); 22 + } 23 + 20 24 public function newValueForUsers($key, array $users) { 21 25 $viewer = $this->getViewer(); 22 26 ··· 53 57 public function getValueFromStorage($value) { 54 58 $parts = explode(',', $value, 2); 55 59 return end($parts); 56 - } 57 - 58 - public function getValueForStorage($value) { 59 - return $value; 60 60 } 61 61 62 62 public function shouldValidateRawCacheData() {
+1 -2
src/applications/people/query/PhabricatorPeopleQuery.php
··· 544 544 545 545 $data = $type->newValueForUsers($cache_key, $need_users); 546 546 547 - foreach ($data as $user_phid => $value) { 548 - $raw_value = $type->getValueForStorage($value); 547 + foreach ($data as $user_phid => $raw_value) { 549 548 $data[$user_phid] = $raw_value; 550 549 $writes[] = array( 551 550 'userPHID' => $user_phid,
+1 -2
src/applications/people/storage/PhabricatorUser.php
··· 1463 1463 if ($user_phid) { 1464 1464 $map = $type->newValueForUsers($key, array($this)); 1465 1465 if (array_key_exists($user_phid, $map)) { 1466 - $usable_value = $map[$user_phid]; 1467 - $raw_value = $type->getValueForStorage($usable_value); 1466 + $raw_value = $map[$user_phid]; 1468 1467 $usable_value = $type->getValueFromStorage($raw_value); 1469 1468 1470 1469 $this->rawCacheData[$key] = $raw_value;