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

Improve Conpherence behavior for logged out users.

Summary:
There are two issues here I was trying to fix:

* Viewing `/conpherence` by logged out users on `secure` would generate an overheated query on `ConpherenceThreadQuery` `secure` has a ton of wacky threads with bogus names.
* When a user views a specific thread that they don't have permission to see, we attempt to fetch the thread's transactions before applying policy filtering. If the thread has more than 1000 comments, that query will also overheat instead of returning a policy exception.

I fixed the first problem, but started trying to fix the second by moving the transaction fetch to `didFilterPage` but it broke in strange ways so I gave up.

Also fix a dangling `qsprintf` update.

Test Plan: Loaded threads and the Conpherence homepage with and without logged in users.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+15 -9
+11 -5
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 136 136 137 137 protected function buildGroupClause(AphrontDatabaseConnection $conn_r) { 138 138 if ($this->participantPHIDs !== null || strlen($this->fulltext)) { 139 - return 'GROUP BY thread.id'; 139 + return qsprintf($conn_r, 'GROUP BY thread.id'); 140 140 } else { 141 141 return $this->buildApplicationSearchGroupClause($conn_r); 142 142 } ··· 192 192 if ($can_optimize) { 193 193 $members_policy = id(new ConpherenceThreadMembersPolicyRule()) 194 194 ->getObjectPolicyFullKey(); 195 + $policies = array( 196 + $members_policy, 197 + PhabricatorPolicies::POLICY_USER, 198 + PhabricatorPolicies::POLICY_ADMIN, 199 + PhabricatorPolicies::POLICY_NOONE, 200 + ); 195 201 196 202 if ($viewer->isLoggedIn()) { 197 203 $where[] = qsprintf( 198 204 $conn, 199 - 'thread.viewPolicy != %s OR vp.participantPHID = %s', 200 - $members_policy, 205 + 'thread.viewPolicy NOT IN (%Ls) OR vp.participantPHID = %s', 206 + $policies, 201 207 $viewer->getPHID()); 202 208 } else { 203 209 $where[] = qsprintf( 204 210 $conn, 205 - 'thread.viewPolicy != %s', 206 - $members_policy); 211 + 'thread.viewPolicy NOT IN (%Ls)', 212 + $policies); 207 213 } 208 214 } 209 215
+4 -4
src/applications/conpherence/view/ConpherenceLayoutView.php
··· 224 224 private function buildNUXView() { 225 225 $viewer = $this->getViewer(); 226 226 227 - $engine = new ConpherenceThreadSearchEngine(); 228 - $engine->setViewer($viewer); 227 + $engine = id(new ConpherenceThreadSearchEngine()) 228 + ->setViewer($viewer); 229 229 $saved = $engine->buildSavedQueryFromBuiltin('all'); 230 230 $query = $engine->buildQueryFromSavedQuery($saved); 231 - $pager = $engine->newPagerForSavedQuery($saved); 232 - $pager->setPageSize(10); 231 + $pager = $engine->newPagerForSavedQuery($saved) 232 + ->setPageSize(10); 233 233 $results = $engine->executeQuery($query, $pager); 234 234 $view = $engine->renderResults($results, $saved); 235 235