When deleting a tag, category or other term I would like to get the IDs of the posts that are related to the term before deletion. Wordpress uses wp_delete_term, which is found in taxonomy.php, to delete a term. In this function the earliest hook is "delete_term_taxonomy". However, it seems like the relationships are already deleted before this hook fires.
I would like to make this query:
SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = $id
This would normally return all the post ids related to a term (category/tag/etc). Is there any other hook I can use? Or maybe a hack?