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

Make caches misses throw by default intead of inline-generating

Summary:
Ref T4103. Ref T10078. Currently, when a user misses a cache we just build it for them.

This is the behavior we want for the the viewer (so we don't have to build every cache up front if we don't actually need them), but not the right behavior for other users (since it allows performance problems to go undetected).

Make inline cache generation strict by default, then make sure all the things that rely on cache data request the correct data (well, all of the things identified by unit tests, at least: there might be some more stuff I haven't hit yet).

This fixes test failures in D16040, and backports a piece of that change.

Test Plan: Identified and then fixed failures with `arc unit --everything`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103, T10078

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

+29 -4
+1
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
··· 163 163 $user = $user_table->loadFromArray($info); 164 164 165 165 $user->attachRawCacheData($cache_raw); 166 + $user->setAllowInlineCacheGeneration(true); 166 167 167 168 switch ($session_type) { 168 169 case PhabricatorAuthSession::TYPE_WEB:
+1
src/applications/metamta/query/PhabricatorMetaMTAActorQuery.php
··· 59 59 $users = id(new PhabricatorPeopleQuery()) 60 60 ->setViewer($this->getViewer()) 61 61 ->withPHIDs($phids) 62 + ->needUserSettings(true) 62 63 ->execute(); 63 64 $users = mpull($users, null, 'getPHID'); 64 65
+3
src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php
··· 337 337 338 338 $all_phids = array_merge($to, $cc); 339 339 if ($all_phids) { 340 + // We need user settings here because we'll check translations later 341 + // when generating mail. 340 342 $users = id(new PhabricatorPeopleQuery()) 341 343 ->setViewer(PhabricatorUser::getOmnipotentUser()) 342 344 ->withPHIDs($all_phids) 345 + ->needUserSettings(true) 343 346 ->execute(); 344 347 $users = mpull($users, null, 'getPHID'); 345 348
-3
src/applications/people/query/PhabricatorPeopleQuery.php
··· 528 528 $cache_data = igroup($cache_data, 'userPHID'); 529 529 foreach ($user_map as $user_phid => $user) { 530 530 $raw_rows = idx($cache_data, $user_phid, array()); 531 - if (!$raw_rows) { 532 - continue; 533 - } 534 531 $raw_data = ipull($raw_rows, 'cacheData', 'cacheKey'); 535 532 536 533 foreach ($keys as $key) {
+16 -1
src/applications/people/storage/PhabricatorUser.php
··· 65 65 66 66 private $settingCacheKeys = array(); 67 67 private $settingCache = array(); 68 + private $allowInlineCacheGeneration; 68 69 69 70 protected function readField($field) { 70 71 switch ($field) { ··· 483 484 } 484 485 485 486 $settings_key = PhabricatorUserPreferencesCacheType::KEY_PREFERENCES; 486 - $settings = $this->requireCacheData($settings_key); 487 + if ($this->getPHID()) { 488 + $settings = $this->requireCacheData($settings_key); 489 + } else { 490 + $settings = array(); 491 + } 487 492 488 493 $defaults = PhabricatorSetting::getAllEnabledSettings($this); 489 494 ··· 1486 1491 return $this; 1487 1492 } 1488 1493 1494 + public function setAllowInlineCacheGeneration($allow_cache_generation) { 1495 + $this->allowInlineCacheGeneration = $allow_cache_generation; 1496 + return $this; 1497 + } 1489 1498 1490 1499 /** 1491 1500 * @task cache ··· 1504 1513 $this->usableCacheData[$key] = $usable_value; 1505 1514 1506 1515 return $usable_value; 1516 + } 1517 + 1518 + // By default, we throw if a cache isn't available. This is consistent 1519 + // with the standard `needX()` + `attachX()` + `getX()` interaction. 1520 + if (!$this->allowInlineCacheGeneration) { 1521 + throw new PhabricatorDataNotAttachedException($this); 1507 1522 } 1508 1523 1509 1524 $usable_value = $type->getDefaultValue();
+8
src/infrastructure/testing/PhabricatorTestCase.php
··· 202 202 $editor->setActor($user); 203 203 $editor->createNewUser($user, $email); 204 204 205 + // When creating a new test user, we prefill their setting cache as empty. 206 + // This is a little more efficient than doing a query to load the empty 207 + // settings. 208 + $user->attachRawCacheData( 209 + array( 210 + PhabricatorUserPreferencesCacheType::KEY_PREFERENCES => '[]', 211 + )); 212 + 205 213 return $user; 206 214 } 207 215