--- Main.php.org 2018-03-18 22:18:00.000000000 +0100 +++ Main.php 2018-04-09 07:58:07.767855400 +0200 @@ -80,7 +80,12 @@ $this->db->query('TRUNCATE '.$this->table.'cache'); $this->db->query('TRUNCATE '.$this->table.'oldlinks'); } else { - $this->db->query('DELETE FROM '.$this->table.'cache WHERE sticky != 1'); + $this->db->query('DELETE '.$this->table.'cache.* FROM ' + .$this->table.'cache LEFT JOIN '.$this->table.'oldlinks ON ' + .$this->table.'cache.id = '.$this->table.'oldlinks.link_id WHERE ' + .$this->table.'cache.sticky != 1 AND (' + .$this->table.'oldlinks.sticky != 1 OR ' + .$this->table.'oldlinks.sticky IS NULL)'); $this->db->query('DELETE FROM '.$this->table.'oldlinks WHERE sticky != 1'); } }