From f7cc269495655330f0d93ab12db845a455d0054b Mon Sep 17 00:00:00 2001 From: frederik Date: Wed, 10 Jul 2024 20:41:03 +0200 Subject: [PATCH] fix: delete picture early, we might not find a replacement later on to overwrite it --- scripts/common.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/common.php b/scripts/common.php index 784da53..103d658 100644 --- a/scripts/common.php +++ b/scripts/common.php @@ -175,6 +175,7 @@ class Flickr { $image = $this->get_image_from_db($sci_name); if ($image !== false && in_array($image['id'], $this->blacklisted_ids)) { $image = false; + $this->delete_image_from_db($sci_name); } if ($image !== false) { $now = new DateTime(); @@ -195,6 +196,12 @@ class Flickr { return $image; } + private function delete_image_from_db($sci_name) { + $statement0 = $this->db->prepare('DELETE FROM images WHERE sci_name == :sci_name'); + $statement0->bindValue(':sci_name', $sci_name); + $statement0->execute(); + } + private function get_image_from_db($sci_name) { $statement0 = $this->db->prepare('SELECT sci_name, com_en_name, image_url, title, id, author_url, license_url, date_created FROM images WHERE sci_name == :sci_name'); $statement0->bindValue(':sci_name', $sci_name);