Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

In Drupal 7, some Taxonomy Terms were deleted (by force from direct DB Query, for some reason). So some Nodes left remained by still tagging this deleted Taxo Terms. Then the problem is arising at the Site Indexing stage. The process is getting broken.

So i believe i need to find the Nodes which are tagging to these no longer existing/broken Taxonomy Terms, to un-tag those.

  • Which is the best way to do it?
  • What will be the best Query for it?

Thanks.

share|improve this question
I notice you also have 14 question, but have only accepted two answers. I've answered your question anyway because I am a stand-up guy and I've found it to be similar to a problem I've had a couple of times ;-) You might want to evaluate some of your previous questions though and accept some answers :) – Chapabu Jan 10 at 9:50

2 Answers

Just as an FYI, even if the terms had been deleted properly, the references still would have been broken (see Database records not deleted for Term Reference Fields after Term is Deleted).

Either way, to answer your question, you could use use super useful Taxonomy Orphanage module.

This module provides interfaces (drush, cron, admin form) for removing orphaned taxonomy term references from entities.

share|improve this answer

Taxonomy Term data is saved in 'taxonomy_term_data' table. And when you add a field e.g. Article Category (machine name - field_category) in your Article Content Type which is of type Term Reference to say Category Vocabulary then system creates a table like 'field_data_field_category'.

Now after knowing your table name for your custom field, you can execute a query which will give you Nodes which are tagging to these no longer existing/broken Taxonomy Terms,

SELECT f.* FROM field_data_field_category f left join taxonomy_term_data t on f.field_category_tid = t.tid WHERE t.tid is null;

Here you just need to specify your table/field name.

share|improve this answer
Huhh, sound interesting but, do i need to run for everrrrrrry field? I have more then 100 fields @_@ – 夏期劇場 Jan 11 at 5:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.