1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Fix improper filtering behavior in ConpherenceParticipantQuery

Summary:
Pathway to D17685. This fixes an issue idenified in D17731: if any caller ever queried for more than one participant, some results could get thrown away by re-keying the results on thread PHID: two different participants can be members of the same thread!

This also fixes an issue from D17683, where a `needParticipantCache()` callsite was overlooked.

Test Plan:
  - Viewed Conpherence dropdown.
  - Sent messages, saw unread count / thread order still work properly.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D17732
This commit is contained in:
epriestley 2017-04-19 12:49:14 -07:00
parent 76d0b67d91
commit f46263903c
4 changed files with 5 additions and 19 deletions

View file

@ -36,8 +36,7 @@ final class ConpherenceQueryThreadConduitAPIMethod
$offset = $request->getValue('offset'); $offset = $request->getValue('offset');
$query = id(new ConpherenceThreadQuery()) $query = id(new ConpherenceThreadQuery())
->setViewer($user) ->setViewer($user);
->needParticipantCache(true);
if ($ids) { if ($ids) {
$conpherences = $query $conpherences = $query
@ -57,7 +56,7 @@ final class ConpherenceQueryThreadConduitAPIMethod
->setLimit($limit) ->setLimit($limit)
->setOffset($offset) ->setOffset($offset)
->execute(); ->execute();
$conpherence_phids = array_keys($participation); $conpherence_phids = mpull($participation, 'getConpherencePHID');
$query->withPHIDs($conpherence_phids); $query->withPHIDs($conpherence_phids);
$conpherences = $query->execute(); $conpherences = $query->execute();
$conpherences = array_select_keys($conpherences, $conpherence_phids); $conpherences = array_select_keys($conpherences, $conpherence_phids);

View file

@ -151,6 +151,7 @@ final class ConpherenceListController extends ConpherenceController {
->withParticipantPHIDs(array($viewer->getPHID())) ->withParticipantPHIDs(array($viewer->getPHID()))
->setLimit($limit) ->setLimit($limit)
->execute(); ->execute();
$all_participation = mpull($all_participation, null, 'getConpherencePHID');
return array( return array(
'all_participation' => $all_participation, 'all_participation' => $all_participation,

View file

@ -12,6 +12,7 @@ final class ConpherenceNotificationPanelController
->withParticipantPHIDs(array($user->getPHID())) ->withParticipantPHIDs(array($user->getPHID()))
->setLimit(5) ->setLimit(5)
->execute(); ->execute();
$participant_data = mpull($participant_data, null, 'getConpherencePHID');
if ($participant_data) { if ($participant_data) {
$conpherences = id(new ConpherenceThreadQuery()) $conpherences = id(new ConpherenceThreadQuery())

View file

@ -25,22 +25,7 @@ final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery {
$this->buildOrderClause($conn), $this->buildOrderClause($conn),
$this->buildLimitClause($conn)); $this->buildLimitClause($conn));
$participants = $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
// TODO: Fix this, it's bogus.
if ('garbage') {
if (count($this->participantPHIDs) !== 1) {
throw new Exception(
pht(
'This query only works when querying for exactly one participant '.
'PHID!'));
}
// This will throw results away if we aren't doing a query for exactly
// one participant PHID.
$participants = mpull($participants, null, 'getConpherencePHID');
}
return $participants;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {