fix: delete picture early, we might not find a replacement later on to overwrite it

This commit is contained in:
frederik
2024-07-10 20:41:03 +02:00
parent 25f2c531c0
commit f7cc269495
+7
View File
@@ -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);