Unverified Commit 0c1e5707 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(locks) Ignore and delete locks older than session lifetime

issue #6143
Showing with 16 additions and 6 deletions
+16 -6
......@@ -242,13 +242,23 @@ class Lock
}
$locks = [];
$sessionLifetime = $config->get_cfg_value('sessionLifetime', 1800);
if ($sessionLifetime > 0) {
$expirationDate = (new DateTime())->sub(new DateInterval('PT'.$sessionLifetime.'S'));
}
while ($attrs = $ldap->fetch()) {
$locks[] = new Lock(
$attrs['dn'],
base64_decode($attrs['fdObjectDn'][0]),
$attrs['fdUserDn'][0],
LdapGeneralizedTime::fromString($attrs['fdLockTimestamp'][0])
);
$date = LdapGeneralizedTime::fromString($attrs['fdLockTimestamp'][0]);
if (isset($expirationDate) && ($date < $expirationDate)) {
/* Delete expired locks */
$ldap->rmdir($attrs['dn']);
} else {
$locks[] = new Lock(
$attrs['dn'],
base64_decode($attrs['fdObjectDn'][0]),
$attrs['fdUserDn'][0],
$date
);
}
}
if (!is_array($objects) && (count($locks) > 1)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment