diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -391,6 +391,10 @@
     return ($epoch - $window);
   }
 
+  public function getEndDateTimeEpochForCache() {
+    return $this->getEndDateTimeEpoch();
+  }
+
   protected function getConfiguration() {
     return array(
       self::CONFIG_AUX_PHID => true,
diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php
--- a/src/applications/people/query/PhabricatorPeopleQuery.php
+++ b/src/applications/people/query/PhabricatorPeopleQuery.php
@@ -465,7 +465,7 @@
         while (true) {
           foreach ($events as $event) {
             $from = $event->getStartDateTimeEpochForCache();
-            $to = $event->getEndDateTimeEpoch();
+            $to = $event->getEndDateTimeEpochForCache();
             if (($from <= $cursor) && ($to > $cursor)) {
               $cursor = $to;
               if (!$next_event) {
@@ -483,7 +483,7 @@
         $availability_type = $invitee->getDisplayAvailability($next_event);
         $availability = array(
           'until' => $cursor,
-          'eventPHID' => $event->getPHID(),
+          'eventPHID' => $next_event->getPHID(),
           'availability' => $availability_type,
         );
 
@@ -496,7 +496,7 @@
         // simultaneously we should accommodate that. However, it's complex
         // to compute, rare, and probably not confusing most of the time.
 
-        $availability_ttl = $next_event->getStartDateTimeEpochForCache();
+        $availability_ttl = $next_event->getEndDateTimeEpochForCache();
       } else {
         $availability = array(
           'until' => null,
diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php
--- a/src/applications/people/storage/PhabricatorUser.php
+++ b/src/applications/people/storage/PhabricatorUser.php
@@ -1082,7 +1082,7 @@
       'UPDATE %T SET availabilityCache = %s, availabilityCacheTTL = %nd
         WHERE id = %d',
       $this->getTableName(),
-      json_encode($availability),
+      phutil_json_encode($availability),
       $ttl,
       $this->getID());
     unset($unguarded);