fix: delete picture early, we might not find a replacement later on to overwrite it
This commit is contained in:
@@ -175,6 +175,7 @@ class Flickr {
|
|||||||
$image = $this->get_image_from_db($sci_name);
|
$image = $this->get_image_from_db($sci_name);
|
||||||
if ($image !== false && in_array($image['id'], $this->blacklisted_ids)) {
|
if ($image !== false && in_array($image['id'], $this->blacklisted_ids)) {
|
||||||
$image = false;
|
$image = false;
|
||||||
|
$this->delete_image_from_db($sci_name);
|
||||||
}
|
}
|
||||||
if ($image !== false) {
|
if ($image !== false) {
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
@@ -195,6 +196,12 @@ class Flickr {
|
|||||||
return $image;
|
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) {
|
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 = $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);
|
$statement0->bindValue(':sci_name', $sci_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user