remove link from md5(userid) on a federation if it is the last

This commit is contained in:
<bdauvergne@entrouvert.com> 1210175579 +0200 0001-01-01 00:00:00 +00:00
parent fc116d9b71
commit e23c502c77
4 changed files with 20 additions and 0 deletions

View File

@ -64,7 +64,16 @@ class LassoSPKitAutoPersistentSession extends LassoSPKitDummySession {
if ($newID) {
$this->storage->rename($oldID, $newID);
} else {
$blob = $this->storage->get($oldID);
$this->storage->delete($oldID);
$userid = $blob['userid'];
if ($userid) {
$md5 = md5($userid);
if ($this->storage->linkcount($md5) == 1) {
$this->storage->delete($md5);
return;
}
}
}
parent::saveFederation();
}

View File

@ -54,5 +54,12 @@ class LassoSPKitFileStore implements LassoSPKitStore {
#lassospkit_debuglog("SPKit File Storage: " . $mesg);
}
}
function linkcount($key) {
$stat = stat($this->filepath($key));
if (is_array($stat)) {
return $stat[3];
}
return 0;
}
}
?>

View File

@ -41,4 +41,7 @@ class LassoSPKitMySqlStore implements LassoSPKitStore {
}
function alias($key,$alias) {
}
function linkcount($key) {
throw new Exception("Not implemented");
}
}

View File

@ -5,6 +5,7 @@ interface LassoSPKitStore {
public function delete($key);
public function alias($key1,$key2);
public function rename($key1, $key2);
public function linkcount($key);
}
?>