Skip to content

Commit

Permalink
Cache the group ids for a day to trade off performance for security u…
Browse files Browse the repository at this point in the history
…pdates.

Fixes ticket #1227.
  • Loading branch information
bharat committed Aug 9, 2010
1 parent 6a8c1f5 commit acb1faa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/gallery/helpers/identity.php
Expand Up @@ -72,12 +72,14 @@ static function load_user() {
auth::login(IdentityProvider::instance()->admin_user());
}

if (!$session->get("group_ids")) {
// Cache the group ids for a day to trade off performance for security updates.
if (!$session->get("group_ids") || $session->get("group_ids_timeout", 0) < time()) {
$ids = array();
foreach ($user->groups() as $group) {
$ids[] = $group->id;
}
$session->set("group_ids", $ids);
$session->set("group_ids_timeout", time() + 86400);
}
} catch (Exception $e) {
// Log it, so we at least have so notification that we swallowed the exception.
Expand Down

0 comments on commit acb1faa

Please sign in to comment.