When a child term is deleted for a node, the node does not automatically get assigned the parent term, if this has not been selected. So this means you end up with nodes that are in a vocabulary, but don't have a term assigned to them.

I've looked at several plugins. But can't find one where I can select in the content section all nodes that don't have a term, and batch add quickly the term to the node.

The following query finds nodes without terms in the database based on node type. You can do this in your favorite MySQL program or phpMyAdmin.

SELECT DISTINCT n.nid, n.title, t.tid FROM node AS n LEFT JOIN node AS t ON n.nid = t.nid WHERE n.type = 'story' AND t.nid IS NULL;

With thanks to: http://drupal.org/node/6051#comment-295948

If you don't want to filter on content type, then remove the ''n.type = 'story' AND". If you want to filter on another content type, then change 'story' to your content type.

Still need a way to batch convert. I read one topic where someone suggested creating new records in node_term, but I'm not sure if this is a safe way to do it. If it is then it would probably be easier to update.

Ideally you would be able in the content menu select nodes that don't have a term, and then batch add taxonomy terms. Similar to the WordPress.

Also maybe a warning message that if you delete a child term off a node it does not go to the parent term.

I'm not sure whether to post this here or in the forums? Or whether it should be core or module territory? Marking this 8.x-dev, as 7 has freeze, and it is not a bug so not for 6. Is that correct?

Comments

Anonymous’s picture

My bad.
Correction that query should be:

SELECT DISTINCT n.nid, n.title, t.tid FROM node AS n LEFT JOIN term_node AS t ON n.nid = t.nid WHERE n.type = 'story' AND t.nid IS NULL;

Lobbed off part of the table name by accident when cleaning up for publication. In addition you need to add the prefix of your table, if you assigned one, to the query, otherwise it won't select:

So for example: prefix_node and prefix_term_node instead of node and term_node.

jhedstrom’s picture

Version: 8.0.x-dev » 8.1.x-dev
Issue tags: +Needs issue summary update
longwave’s picture

Status: Active » Closed (won't fix)

The SQL query described here could be built in Views, but I think warning or preventing the user from orphaning a node is a job for contrib rather than core.