diff --git a/classes/OccurrenceEditorDeterminations.php b/classes/OccurrenceEditorDeterminations.php index 139f70331c..3c9089012b 100644 --- a/classes/OccurrenceEditorDeterminations.php +++ b/classes/OccurrenceEditorDeterminations.php @@ -258,7 +258,17 @@ private function updateBaseOccurrence($detId){ if(isset($taxonArr['tid']) && $taxonArr['tid']) $sql .= ', o.tidinterpreted = '.$taxonArr['tid']; if(isset($taxonArr['security']) && $taxonArr['security']) $sql .= ', o.localitysecurity = '.$taxonArr['security'].', o.localitysecurityreason = ""'; $sql .= ' WHERE (d.iscurrent = 1) AND (d.detid = '.$detId.')'; - $this->conn->query($sql); + $updated_base = $this->conn->query($sql); + + //Whenever occurrence is updated also update associated images + if($updated_base && isset($taxonArr['tid']) && $taxonArr['tid']) { + $sql = <<<'SQL' + UPDATE images i + INNER JOIN omoccurdeterminations od on od.occid = i.occid + SET tid = ? WHERE detid = ?; + SQL; + $this->conn->execute_query($sql, [$taxonArr['tid'], $detId]); + } } }