ReportQueries.php: delete then invalidate cache

This commit is contained in:
Zankaria 2024-12-06 22:48:26 +01:00
parent f29f626eb1
commit b5622e20c5

View file

@ -200,11 +200,11 @@ class ReportQueries {
* @param int $id The report id. * @param int $id The report id.
*/ */
public function deleteById(int $id) { public function deleteById(int $id) {
// The caller may actually delete a valid post, so we need to invalidate the cache.
$this->cache->delete(self::CACHE_KEY);
$query = $this->pdo->prepare("DELETE FROM `reports` WHERE `id` = :id"); $query = $this->pdo->prepare("DELETE FROM `reports` WHERE `id` = :id");
$query->bindValue(':id', $id, \PDO::PARAM_INT); $query->bindValue(':id', $id, \PDO::PARAM_INT);
$query->execute(); $query->execute();
// The caller may actually delete a valid post, so we need to invalidate the cache.
$this->cache->delete(self::CACHE_KEY);
} }
/** /**
@ -213,11 +213,11 @@ class ReportQueries {
* @param int $ip The reporter ip. * @param int $ip The reporter ip.
*/ */
public function deleteByIp(string $ip) { public function deleteByIp(string $ip) {
// The caller may actually delete a valid post, so we need to invalidate the cache.
$this->cache->delete(self::CACHE_KEY);
$query = $this->pdo->prepare("DELETE FROM `reports` WHERE `ip` = :ip"); $query = $this->pdo->prepare("DELETE FROM `reports` WHERE `ip` = :ip");
$query->bindValue(':ip', $ip); $query->bindValue(':ip', $ip);
$query->execute(); $query->execute();
// The caller may actually delete a valid post, so we need to invalidate the cache.
$this->cache->delete(self::CACHE_KEY);
} }
/** /**