From eac49e421a4192218e491662c51ef5fa9c7a8e00 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 Nov 2016 15:08:15 -0800 Subject: [PATCH] Fix an issue where an excessively long TTL was computed for "not attending anything" event caches Summary: Fixes T11894. Currently, if you aren't attending any events for a while, we can cache that you are free for the next 72 hours, even if you have an event in a few hours. Instead, only cache "user is free" until the next event, if one exists. Test Plan: Dumped cache TTLs, saw 52 minutes instead of ~4300 minutes with a near-upcoming event. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11894 Differential Revision: https://secure.phabricator.com/D16937 --- src/applications/people/query/PhabricatorPeopleQuery.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php index 32ae31859b..3af1c4f167 100644 --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -498,7 +498,16 @@ final class PhabricatorPeopleQuery 'eventPHID' => null, 'availability' => null, ); + + // Cache that the user is available until the next event they are + // invited to starts. $availability_ttl = $max_range; + foreach ($events as $event) { + $from = $event->getStartDateTimeEpochForCache(); + if ($from > $cursor) { + $availability_ttl = min($from, $availability_ttl); + } + } } // Never TTL the cache to longer than the maximum range we examined.