updateLastAction() public method

Update the last_action column in the entities table for $guid.
public updateLastAction ( ElggEntit\ElggEntity $entity, integer $posted = null ) : integer | false
$entity ElggEntit\ElggEntity Entity annotation|relationship action carried out on
$posted integer Timestamp of last action
return integer | false
コード例 #1
0
ファイル: UsersTable.php プロジェクト: elgg/elgg
 /**
  * Sets the last action time of the given user to right now.
  *
  * @see _elgg_session_boot The session boot calls this at the beginning of every request
  *
  * @param ElggUser $user User entity
  * @return void
  */
 public function setLastAction(ElggUser $user)
 {
     $time = $this->getCurrentTime()->getTimestamp();
     if ($user->last_action == $time) {
         // no change required
         return;
     }
     $query = "\n\t\t\tUPDATE {$this->table}\n\t\t\tSET\n\t\t\t\tprev_last_action = last_action,\n\t\t\t\tlast_action = :last_action\n\t\t\tWHERE guid = :guid\n\t\t";
     $params = [':last_action' => $time, ':guid' => (int) $user->guid];
     $user->prev_last_action = $user->last_action;
     $user->last_action = $time;
     execute_delayed_write_query($query, null, $params);
     $this->entity_cache->set($user);
     // If we save the user to memcache during this request, then we'll end up with the
     // old (incorrect) attributes cached (notice the above query is delayed). So it's
     // simplest to just resave the user after all plugin code runs.
     register_shutdown_function(function () use($user, $time) {
         $this->entities->updateLastAction($user, $time);
         // keep entity table in sync
         $user->storeInPersistedCache(_elgg_get_memcache('new_entity_cache'), $time);
     });
 }