/**
  * Find taxonomy with the same term ID and taxonomy (type) as for the
  * provided taxonomy. If a match is found, update provided taxonomy with
  * the taxonomy ID we got from database.
  *
  * Useful for comparing a post sent from content staging to production.
  *
  * @param Taxonomy $taxonomy
  *
  * @throws Exception
  */
 public function get_taxonomy_id_by_taxonomy(Taxonomy $taxonomy)
 {
     $term = $taxonomy->get_term();
     // Ensure that the term is set.
     if ($term === null) {
         $message = sprintf('No term found for term_taxonomy_id %d in table %s', $taxonomy->get_id(), $this->wpdb->term_taxonomy);
         throw new Exception($message);
     }
     $query = $this->wpdb->prepare('SELECT term_taxonomy_id FROM ' . $this->get_table() . ' WHERE term_id = %d AND taxonomy = %s', $taxonomy->get_term()->get_id(), $taxonomy->get_taxonomy());
     $row = $this->wpdb->get_row($query, ARRAY_A);
     if (isset($row['term_taxonomy_id'])) {
         $taxonomy->set_id($row['term_taxonomy_id']);
     } else {
         $taxonomy->set_id(null);
     }
 }
 /**
  * @param Taxonomy $taxonomy
  */
 public function set_taxonomy(Taxonomy $taxonomy)
 {
     $this->set_id($this->post->get_id() . '-' . $taxonomy->get_id());
     $this->taxonomy = $taxonomy;
 }