Skip to content

Commit e1400c2

Browse files
tamil-rssthijskh
authored andcommitted
feat(pdo): add removeEntry method to clear expired metadata
1 parent e1f713f commit e1400c2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,31 @@ public function addEntry(string $index, string $set, array $entityData): bool
255255
}
256256

257257

258+
/**
259+
* Remove metadata from the configured database
260+
*
261+
* @param string $entityId The entityId we are removing.
262+
* @param string $set The set to remove the metadata from.
263+
*
264+
* @return bool True/False if entry was successfully deleted
265+
*/
266+
public function removeEntry(string $entityId, string $set): bool
267+
{
268+
if (!in_array($set, $this->supportedSets, true)) {
269+
return false;
270+
}
271+
272+
$tableName = $this->getTableName($set);
273+
274+
$rows = $this->db->write(
275+
"DELETE FROM $tableName WHERE entity_id = :entity_id",
276+
['entity_id' => $entityId]
277+
);
278+
279+
return $rows === 1;
280+
}
281+
282+
258283
/**
259284
* Replace the -'s to an _ in table names for Metadata sets
260285
* since SQL does not allow a - in a table name.

0 commit comments

Comments
 (0)