1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Fix two Calendar availability cache issues

Summary:
Fixes T12661.

When changing the start date of an event from some time in the past to some time significantly in the future (more than 24 hours), we'd invalidate only future caches and leave users in an "away" state. Instead, just invalidate all past and future caches (this is simpler than trying to figure out a narrower window, and should not make us do too much extra work).

When uninviting users from events, their caches also didn't get cleared correctly. Instead, clear them.

Test Plan:
  - Changed an event from "Apr 1 - June 1" to "May 15 - June 1", saw availablity clear properly.
  - Uninvited user `@dog` from an ongoing event, saw availability clear properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12661

Differential Revision: https://secure.phabricator.com/D17809
This commit is contained in:
epriestley 2017-05-01 10:37:12 -07:00
parent da6d624fe8
commit 0ebe56be40

View file

@ -127,6 +127,9 @@ final class PhabricatorCalendarEventEditor
// Clear the availability caches for users whose availability is affected
// by this edit.
$phids = mpull($object->getInvitees(), 'getInviteePHID');
$phids = array_fuse($phids);
$invalidate_all = false;
$invalidate_phids = array();
foreach ($xactions as $xaction) {
@ -146,16 +149,21 @@ final class PhabricatorCalendarEventEditor
$invalidate_phids[$acting_phid] = $acting_phid;
break;
case PhabricatorCalendarEventInviteTransaction::TRANSACTIONTYPE:
foreach ($xaction->getNewValue() as $phid => $ignored) {
foreach ($xaction->getOldValue() as $phid) {
// Add the possibly un-invited user to the list of potentially
// affected users if they are't already present.
$phids[$phid] = $phid;
$invalidate_phids[$phid] = $phid;
}
foreach ($xaction->getNewValue() as $phid) {
$invalidate_phids[$phid] = $phid;
}
break;
}
}
$phids = mpull($object->getInvitees(), 'getInviteePHID');
$phids = array_fuse($phids);
if (!$invalidate_all) {
$phids = array_select_keys($phids, $invalidate_phids);
}
@ -168,10 +176,9 @@ final class PhabricatorCalendarEventEditor
queryfx(
$conn_w,
'UPDATE %T SET availabilityCacheTTL = NULL
WHERE phid IN (%Ls) AND availabilityCacheTTL >= %d',
WHERE phid IN (%Ls)',
$user->getTableName(),
$phids,
$object->getStartDateTimeEpochForCache());
$phids);
}
return $xactions;